You are on page 1of 2

void loop()

if((switchoff) == LOW)
{
digitalWrite(switchoff, LOW);
Angle = map(voltage,0,0,0,0);
digitalWrite(LEDGREEN,LOW);
digitalWrite(LEDBLUE,LOW);
myservo.write(Angle);
}

if(switchup = HIGH)
{

if (digitalRead(voltage)<.9 & digitalRead(voltage)>0.0)


{
Angle = map(voltage,0,0.9,-55,0); //Reads angle sets angle
//digitalWrite(LEDBLUE,LOW);
//digitalWrite(LEDGREEN,LOW);
myservo.write(Angle);
//analogWrite(Angle); // rotat at a specified angle // tell servo to go to
position in variable 'pos'
; // waits 15ms for the servo to reach the position
}
if (digitalRead(voltage)>=1 & digitalRead(voltage)<=3)
{
Angle = map(voltage,1,3,-179,0); //Reads angle sets angle
digitalWrite(LEDGREEN,HIGH);
//digitalWrite(LEDBLUE,LOW);
myservo.write(Angle);
//analogWrite(Angle); // rotat at a specified angle // tell servo to go to
position in variable 'pos'
// waits 15ms for the servo to reach the position
}
delay(1000);
}

if(switchdown == HIGH)
{
if(digitalRead(voltage)>0 & digitalRead(voltage)<=2.9)
{
Angle = map(voltage,0,2.9,-55,0); //Reads angle sets angle
//digitalWrite(LEDGREEN,LOW);
//digitalWrite(LEDBLUE,LOW);
myservo.write(Angle);// rotat at a specified angle // tell servo to go
to position in variable 'pos'
// waits 15ms for the servo to reach the position
}
if (digitalRead(voltage)>=3 & digitalRead(voltage)<=5)
{
Angle = map(voltage,3,5,-179,0); //Reads angle sets angle
digitalWrite(LEDBLUE,HIGH);
digitalWrite(LEDGREEN,LOW);
myservo.write(Angle);// rotat at a specified angle // tell servo to go
to position in variable 'pos'
// waits 15ms for the servo to reach the position
}
delay(1000);
}