#include <Servo.h>
Servo myServo;
const int buttonPin1 = 4;
const int buttonPin2 = 5;
int servopin = 3;
int angle = 90;
void setup() {
myServo.attach(servopin);
pinMode(buttonPin1, INPUT_PULLUP);
pinMode(buttonPin2, INPUT_PULLUP);
}
void loop() {
myServo.write(angle);
if (digitalRead(buttonPin1) == LOW) {
if (angle < 180) {
angle++;
myServo.write(angle);
}
delay(20);
}
if (digitalRead(buttonPin2) == LOW) {
if (angle > 0) {
angle--;
myServo.write(angle);
}
delay(20);
}
}