/*
Controlling a servo position using a potentiometer (variable resistor)
by Michal Rinott <http://people.interaction-ivrea.it/m.rinott>
modified on 8 Nov 2013
by Scott Fitzgerald
http://www.arduino.cc/en/Tutorial/Knob
*/
#include <Servo.h>
Servo myservo; // create servo object to control a servo
int potpin = 0; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin
int button = 6;
bool buttonFlag = true;
void setup() {
myservo.attach(9); // attaches the servo on pin 9 to the servo object
pinMode(button, INPUT_PULLUP);
}
void loop() {
if (digitalRead(button) == LOW && buttonFlag == true){
myservo.write(0);
delay(1000);
//buttonFlag = false;
}else{
myservo.write(90);
delay(1000);
myservo.write(100);
delay(2000);
}
}