const int analogInPin1 = A0; // Analog input pin that the proximity sensor1 connected to the front side of the door const int analogInPin2 = A1; const int outputPin=13;// Analog input pin that the proximity sensor2 connected to the back side of the door int sValue1 = 0; // value read from the proximity sensor1 int sValue2 = 0;// value read from proximity sensor 2 int threshold; int counter=0; void setup() {pinMode(outputPin,OUTPUT); // initialize serial communications at 9600 bps: Serial.begin(9600); } void loop() { // read the analog in value: sValue1 = analogRead(analogInPin1); sValue2= analogRead(analogInPin2); int V1,V2; V1 = map(sValue1, 0, 1023, 0, 255); V2 = map(sValue2, 0, 1023, 0, 255); if(V1>threshold) //the threshold value is to be callibrated by you accordint to the lighting effects { counter= counter+1; } if(V2>threshold); { counter=counter-1;} if(counter>0) {digitalWrite(outputPin,HIGH); } else if (counter=0) {digitalWrite(outputPin,LOW); } delay(1000); }