const int analogPin = A0; // potentiometer wiper (middle terminal) connected to analog pin 3 const int DigitalPin = 13; #include Servo myservo; // create servo object to control a servo Servo myservo2; int potpin1 = A1; // analog pin used to connect the potentiometer int potpin2 = A2; int val = 0; int val2; int val3; // variable to store the value read void setup() { Serial.begin(9600); // setup serial pinMode(DigitalPin, OUTPUT); myservo.attach(9); // attaches the servo on pin 9 to the servo myservo2.attach(10); } void loop() { val2 = analogRead(potpin1); // reads the value of the potentiometer (value between 0 and 1023) val2 = map(val2, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180) myservo.write(val2); // sets the servo position according to the scaled value val3 = analogRead(potpin2); // reads the value of the pot val3 = map(val3, 0, 1023, 0, 179); // scale it between 0 and 180 myservo2.write(val3); delay(15); // waits for the servo to get there val = analogRead(analogPin); // read the input pin Serial.println(val); // debug value Serial.println(analogRead(analogPin)); if (val >= 500) { digitalWrite(DigitalPin, LOW); Serial.println(" Dark - SAFE "); delay(15); } else { digitalWrite(DigitalPin, HIGH); Serial.println(" Light - EXPLOSION "); } delay(15); }