#include <Servo.h>
Servo myservo; // create servo object to control a servo
// twelve servo objects can be created on most boards
int pos = 0; // variable to store the servo position
int redbut = 6;
int grbut = 7;
int step = 10;
void setup() {
myservo.attach(9); // attaches the servo on pin 9 to the servo object
pinMode(redbut, INPUT_PULLUP);
pinMode(grbut, INPUT_PULLUP);
myservo.write(pos);
}
void loop() {
if ((digitalRead(redbut)== LOW)){
if (pos<180) {
pos+=step;
myservo.write(pos);
delay(500);
}
}
if ((digitalRead(grbut)== LOW)){
if (pos>0){
pos-=step;
myservo.write(pos);
delay(500);
}
}
}