Stepper Motor
hi! trying run motor following program. want motor stop when send zero. according following program motor keeps running @ value put in variable 'step' @ first, not update. great if can me it.
thanks
thanks
code: [select]
#include <stepper.h>
// change number of steps on motor
int steps;
int speed;
stepper stepper(100, 4, 5, 6, 7);
void setup()
{
while (!serial);
serial.begin(9600);
serial.println("motor speed? "); //prompt user input
while (serial.available()==0){ } //wait user input
speed = serial.parseint(); //read user input
stepper.setspeed(speed);
}
void loop()
{
if(serial.available())
{
int steps = serial.parseint();
while(steps!=0){
stepper.step(steps);
if(serial.available())
{
int steps = serial.parseint();}
}}
}
code: [select]
if(serial.available())
{
int steps = serial.parseint();}
}}
there world of difference between int steps = ... , steps = ... learn difference is.
Arduino Forum > Using Arduino > Programming Questions > Stepper Motor
arduino
Comments
Post a Comment