at initial when uploaded code, stepper motor able step 6 times , when unplugged usb power , plugged in again motor step backwards once , move forward 5 times. can explain me what's going on. below coding.
code: [select]
#include <stepper.h>
const int stepsperrevolution = 48; // change fit number of steps per revolution
// motor
// initialize stepper library on pins 8 through 11:
stepper mystepper(stepsperrevolution, 2,3,4,5);
int stepcount = 0; // number of steps motor has taken
void setup() {
// initialize serial port:
serial.begin(9600);
for(int = 0; <= 12; i++){
mystepper.step(1);
serial.print("steps:" );
serial.println(stepcount);
stepcount++;
delay(500);
}
}
code: [select]
#include <stepper.h>
const int stepsperrevolution = 48; // change fit number of steps per revolution
// motor
// initialize stepper library on pins 8 through 11:
stepper mystepper(stepsperrevolution, 2,3,4,5);
int stepcount = 0; // number of steps motor has taken
void setup() {
// initialize serial port:
serial.begin(9600);
}
void loop()
{
for(int = 0; <= 12; i++)
{
mystepper.step(1);
serial.print("steps:" );
serial.println(stepcount);
stepcount++;
delay(500);
}
}
you dont have loop function in code. upload code
Arduino Forum > Using Arduino > Programming Questions > Question on stepper motor functionality
arduino
Comments
Post a Comment