This idea is good for automatic turning on and off multiple lights one by one while a person is walking staircase or walking through a passage or hallway. As IR Obstacle Sensors has physical limits, we can not use if the passage is wide like a road – it will fail for physical reasons. Human is not much thick too! In our previous guides – Arduino IR Obstacle Detection Sensor For Dimming LED and Arduino LED Switch On By Push Button Switch Off By IR Obstacle Sensor, we turned LED off facing obstacle.
Arduino : Light ON One By One Following Foot Steps on Staircase
We can reverse the action i.e. TURN ON LED facing obstacle by minimum modification :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | int LED = 13; int obstaclePin = 7; int hasObstacle = HIGH; void setup() { pinMode(LED, OUTPUT); pinMode(obstaclePin, INPUT); } void loop() { hasObstacle = digitalRead(obstaclePin); if (hasObstacle == HIGH) { digitalWrite(LED, HIGH); } else { digitalWrite(LED, LOW); } delay(200); } |
With Arduino, We Can Turn Light ON One By One Following Foot Steps on Staircase or Hallway. So As the Person Leave a Position, Light Turns Off. That is possible if we use multiple IR Obstacle Detection Sensors and multiple LEDs as model and in real, instead of LED, AC light with relay module.
---
With four IR Obstacle Sensors and 6 LEDs, circuit diagram is practically same like older guide. Only each LED and IR will use different pins.
With four IR Obstacle Sensors and 6 LEDs, our code will go like this :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | int ir1=2; int ir2=3; int ir3=4; int ir4=5; int led1=6; int led2=7; int led3=8; int led4=9; int led5=10; int led6=11; int proxy1=0; int proxy2=0; int proxy3=0; int proxy4=0; void setup() { pinMode(ir1,INPUT); pinMode(ir2,INPUT); pinMode(ir3,INPUT); pinMode(ir4,INPUT); pinMode(led1,OUTPUT); pinMode(led2,OUTPUT); pinMode(led3,OUTPUT); pinMode(led4,OUTPUT); pinMode(led5,OUTPUT); pinMode(led6,OUTPUT); } void loop(){ proxy1=digitalRead(ir1); proxy2=digitalRead(ir2); proxy3=digitalRead(ir3); proxy4=digitalRead(ir4); if(proxy1==HIGH) { digitalWrite(led1,LOW); digitalWrite(led2,LOW); digitalWrite(led3,LOW); } else { digitalWrite(led1,HIGH); digitalWrite(led2,HIGH); digitalWrite(led3,HIGH); } if(proxy2==HIGH) { digitalWrite(led2,LOW); digitalWrite(led3,LOW); digitalWrite(led4,LOW); } else { digitalWrite(led2,HIGH); digitalWrite(led3,HIGH); digitalWrite(led4,HIGH); } if(proxy3==HIGH) { digitalWrite(led3,LOW); digitalWrite(led4,LOW); digitalWrite(led5,LOW); } else { digitalWrite(led3,HIGH); digitalWrite(led4,HIGH); digitalWrite(led5,HIGH); } if(proxy4==HIGH) { digitalWrite(led4,LOW); digitalWrite(led5,LOW); digitalWrite(led6,LOW); } else { digitalWrite(led4,HIGH); digitalWrite(led5,HIGH); digitalWrite(led6,HIGH); } } |