#include Servo servo; void setup() { Serial.begin(9600); pinMode(2, OUTPUT); pinMode(3, OUTPUT); pinMode(4, OUTPUT); pinMode(5, OUTPUT); servo.attach(10); } void loop() { int x = analogRead(A0); Serial.print("x:"); Serial.println(x); if(x <= 140){ digitalWrite(2, LOW); digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(5, LOW); servo.write(0); } else if(x > 140 && x <= 280){ digitalWrite(2, HIGH); digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(5, LOW); servo.write(40); } else if(x > 280 && x <= 420){ digitalWrite(2, HIGH); digitalWrite(3, HIGH); digitalWrite(4, LOW); digitalWrite(5, LOW); servo.write(80); } else if(x > 420 && x <= 580 ){ digitalWrite(2, HIGH); digitalWrite(3, HIGH); digitalWrite(4, HIGH); digitalWrite(5, LOW); servo.write(120); } else { digitalWrite(2, HIGH); digitalWrite(3, HIGH); digitalWrite(4, HIGH); digitalWrite(5, HIGH); servo.write(180); } delay(100); }