Setspeed() does not work !

# include<AccelStepper.h>
const int dirPin = 3;          // Pin which is used to accept the signal that determine the rotational speed of the motor
const int stepPin =2;         // Pin which is used to accept the pulse signal(one pulse corresponds to one step only)
float speed = 100;
AccelStepper myStepper(1,stepPin,dirPin);                    // Easy Driver mode
void setup() {
  // put your setup code here, to run once:
  //myStepper.setSpeed(100);
  myStepper.move(100);
  myStepper.setSpeed(speed);
  Serial.begin(9600);
  Serial.println(myStepper.speed());
}

void loop() {
  // put your main code here, to run repeatedly:
    myStepper.runSpeed();
    Serial.print("CUS POS:");
    Serial.println(myStepper.currentPosition());

The speed of motor is always one, can any tell me what happen ?

What type of variable does setSpeed() take as a parameter ?

float or long ?

have you tried including setMaxSpeed() first in setup()?

Bear in my that if you are using a stepper motor, once it has reached myStepper.move(100); position the motor will stop moving.

You are printing inside function loop() with 9600 baud.
This is slowing down how fast function loop can loop
As a test comment out all serial printing

best regards Stefan

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.