I have this project I'm working on where I'll need the speed of the stepper motor to change set speed at a certain distance, I just can't figure out a way to do it. I'm using arduino and a stepper motor, this is the current code.
#include <AccelStepper.h>
AccelStepper stepper1(AccelStepper::FULL4WIRE, 0, 1, 2, 3);
void setup()
{
stepper1.setMaxSpeed(200.0);
stepper1.setAcceleration(400.0);
stepper1.moveTo(5000);
}
void loop()
{
// Change direction at the limits
if (stepper1.distanceToGo() == 0)
stepper1.moveTo(-stepper1.currentPosition());
stepper1.run();
What I want it to do basically is to first moveTo(2500)
at the current speed 200 then after 2500 I want it to increase speed to 400. After it has moved 5000 it turns and moves back to position but that's implemented already.