hi I am using a button to control two continuous servo motors the button is a input pullup but when I press the button nothing happens, when I checked Serial monitor when button is pressed it only returns a value 1 never 0 I don't know why. here is code also circuit is below.
[code]
#include <Servo.h>
Servo rightMotor;
Servo leftMotor;
const int button = 12;
int buttonPress = 0;
void setup(){
rightMotor.attach(5);
leftMotor.attach(6);
pinMode(button, INPUT_PULLUP);
Serial.begin(9600);
}
void loop(){
buttonPress = digitalRead(button);
Serial.print(buttonPress);
Serial.println(" ");
if(buttonPress == LOW){
moveForward(1000);
Stop(500);
turnRight(800);
Stop(500);
turnLeft(800);
Stop(500);
moveBack(800);
Stop(300);
turnRight(300);
Stop(300);
}
else{
stopAll();
}
}
void moveForward(int delay1){
rightMotor.write(0);
leftMotor.write(180);
delay(delay1);
}
void moveBack(int delay2){
rightMotor.write(180);
leftMotor.write(0);
delay(delay2);
}
void turnRight(int delay3){
rightMotor.write(0);
leftMotor.write(91);
delay(delay3);
}
void turnLeft(int delay4){
rightMotor.write(91);
leftMotor.write(180);
delay(delay4);
}
void Stop(int delay5){
rightMotor.write(91);
leftMotor.write(91);
delay(delay5);
}
void stopAll(){
rightMotor.write(91);
leftMotor.write(91);
}
[/code]

