#include<Servo.h>
Servo myservo;
int servoPin = 9;
int potpin = A0 ;
int val ;
int Led1 = 8;
int Led2 = 7;
void setup() {
// put your setup code here, to run once:
myservo.attach (servoPin);
pinMode (Led1, OUTPUT);
pinMode (Led2, OUTPUT);
pinMode (potpin, INPUT );
}
void loop() {
// put your main code here, to run repeatedly:
val = analogRead (potpin);
val = map (val, 0, 1023, 0, 179);
myservo.write(val);
if (val > 30){
digitalWrite (Led1, HIGH);
}
if (val > 90){
digitalWrite (Led2, HIGH);
}
else{
digitalWrite(Led1, LOW);
digitalWrite(Led2, LOW);
}
}