Hi all
Im trying to control a stepper motor with buttons.
Basicly what im trying to do here is when a button is pressed rotate to one diraction and then to another, when another button is pressed stop the motor.
This is my code:
void setup()
{
pinMode(2, INPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, INPUT);
}
void loop()
{
bool push=digitalRead(2);
bool sw=digitalRead(12);
if (sw==HIGH)
{
int i=0;
for(i=0;i<512;i++)
{
if (push==1)
break;
clockwiserotate();
}
delay(1000);
for(i=0;i<512;i++)
{
if (push==1)
break;
counterclockwiserotate();
}
delay(1000);
}
The thing is, it doesnt stop when i press the button and it also shows me when im pressing the button that the voltage is 0
Thanks for the help!