//Dimas Rama
//5CD
#include <Servo.h>
Servo servoMotor;
int pos = 0;
int buttonState = 0;
const int pushbutton = 4;
const int led = 2;
void setup() {
servoMotor.attach(15);
pinMode(2, OUTPUT);
pinMode(4, INPUT);
}
void loop() {
buttonState = digitalRead(pushbutton);
if (buttonState == HIGH)
for (pos = 0; pos <= 180; pos += 1){
digitalWrite(2, HIGH);
servoMotor.write(pos);
delay(15);
}
for (pos = 180; pos <= 0; pos -= 1){
digitalWrite(2, HIGH);
servoMotor.write(pos);
delay(15);
}
buttonState = digitalRead(pushbutton);
if (buttonState == LOW)
digitalWrite(2, LOW);
servoMotor.write(0);
delay(15);
}