[code]#include <Servo.h> //
Servo myservo; // creating myservo object
int buttonPin = 36; // set button pin
int buttonState = 0; // set buttonState
int buttonPin2 = 32; // set button pin
int buttonState2 = 0; // set buttonState
int led = 13;
int dirA = 12;
int dirB = 13;
int speedA = 3;
int speedB = 11;
void setup()
{
myservo.attach(40); // attach the 2 pin to servo
pinMode(buttonPin, INPUT);
pinMode(buttonPin2, INPUT);
pinMode(led, OUTPUT);
}
void loop()
{
buttonState = digitalRead(buttonPin);
buttonState2 = digitalRead(buttonPin2);
for (int i = 0 ; i <1 ;i++){
if (buttonState == LOW){
myservo.write(180);
delay(1000);
myservo.write(0);
delay(1000);
delay(2000);
analogWrite (speedA, 1000);
analogWrite (speedB, 1000);
digitalWrite (dirA, HIGH);
digitalWrite (dirB, HIGH);
if (buttonState2 == LOW){
analogWrite (speedA, LOW);
delay(3000);// delay unwind
analogWrite (speedB, LOW);
if (buttonState2 == HIGH){
analogWrite (speedA, 1000);
analogWrite (speedB, 1000);
digitalWrite (dirA, HIGH);
digitalWrite (dirB, HIGH);
if (buttonState == HIGH){
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000);
}
}
}
}
}
}
I was trying to run this code but it stopped right before it says "if (buttonState2 == LOW){". I couldn't find what was wrong but i was wondering if anyone could tell me?
[/code]