#include Servo myservo; const int buttonPin = 8; int buttonState = 0; void setup() { // put your setup code here, to run once: pinMode(buttonPin, INPUT); myservo.attach(5); } void loop() { buttonState = digitalRead(buttonPin); if (buttonState == LOW) { myservo.write(0); } else { myservo.write(180); } }