Hi guys,
I fixed it thanks for your help.
Greetings Jeroen
#include <Servo.h>
Servo myservo;
const int buttonPin1 = 2;
const int buttonPin2 = 3;
const int buttonPin3 = 4;
int count = 0;
int buttonState1 = 0;
int buttonState2 = 0;
int buttonState3 = 0;
void setup() {
pinMode(buttonPin1, INPUT);
pinMode(buttonPin2, INPUT);
pinMode(buttonPin3, INPUT);
Serial.begin(9600);
myservo.attach(7);
myservo.writeMicroseconds(1508);
}
void loop(){
buttonState1 = digitalRead(buttonPin1);
buttonState2 = digitalRead(buttonPin2);
buttonState3 = digitalRead(buttonPin3);
if (buttonState1 == HIGH) {
myservo.write(0);
delay(400);
Serial.println("button1 naar voren");
}
if (buttonState2 == HIGH) {
myservo.write(180);
delay(400);
Serial.println("button2 naar achter");
}
if (buttonState3 == HIGH) {
count++;
delay(400);
Serial.println("button3");
}
if (buttonState3 == HIGH && count == 1) {
myservo.write(0);
delay(400);
Serial.println("button3 start");
}
if (buttonState3 == HIGH && count >= 2) {
myservo.writeMicroseconds(1508);
delay(400);
Serial.println("button3 stop");
}
}