#include <Servo.h>
Servo myservo; // create servo object to control a servo
int button_pin = 4;
int button_value;
void setup() {
myservo.attach(9); // attaches the servo on pin 9 to the servo object
pinMode(button_pin, INPUT_PULLUP);
}
void loop() {
button_value = digitalRead(button_pin);
if (button_value == 1) {
myservo.write(0);
} else if (button_value == 0) {
myservo.write(180);
}
delay(100);
}