Motion Controlled Walk in Light System With Arduino
This Simple Project aims to build a motion controlled light system using a PIR sensor,Relay & Arduino.
This type of systems are ideal for hallways, corridors, passages, stairs or any other places.
Using this system we can automatically turn off unnecessary lamps and save energy.
Also it saves the trouble of finding the light switch in the dark.
When the motion is detected by the sensor in a certain area, the lamp will turn on and stays turned on for a certain time period.
In that time period, the person can enter that area, finish his work and leave.
If the person expects to stay in that area for longer than adjusted time period, then he can simply turn on the switch.This will override the sensor controlled system and now the lamp will operate as a normal switch controlled lamp.
For switch back to sensor controlled system , simply turn off the switch, and the system will now operate as described above.
Note that the PIR sensor range is between 3m and 7m with 100° degree cone area.
Tools & Components
1 X Arduino Nano1 X 5VDC Relay
1 X HC-SR501 PIR Sensor Module
1 X 230V/110V Lamp
1 X Switch
1 X 5VDC Power Source
Connecting Wires
Connecting Components
PIR Sensor Signal in - Arduino D02
Relay Module Signal in - Arduino D12
The Below Arduino Code is written to switch on the lamp for a time period of 1 minitue.
Arduino Code
int Relay = 12;int sensor = 2;
int state = LOW;
int val = 0;
void setup() {
pinMode(Relay, OUTPUT);
pinMode(sensor, INPUT);
Serial.begin(9600);
}
void loop(){
val = digitalRead(sensor);
if (val == HIGH) {
digitalWrite(Relay, HIGH);
delay(60000);
if (state == LOW) {
Serial.println("Lamp On");
state = HIGH;
}
}
else {
digitalWrite(Relay, LOW);
delay(200);
if (state == HIGH){
Serial.println("Lamp Off!");
state = LOW;
}
}
}
Safety First !
Always Connect the main power supply if you are absolutely sure that the components are connected correctly without changing polarity and short circuited the wiring.
Even if it seems nothing is wrong : DOUBLE CHECK EVERYTHING !!Your Feedback is very important to us.Please Leave a comment about how you feel about this project.
Post a Comment