Thursday, August 17, 2017

Project III - 16. Automatic Bathroom Lights with Pir Sensor based On Arduino

Automatic Bathroom Lights with Pir Sensor


The Arduino UNO will be used to control "ON - OFF" bathroom lights automatically with PIR (Passive Infra Red) sensors. If someone enters the bathroom, the sensor will detect the passive infra-red waves emitted by that person and then the arduino will program the relay for On so that the lamp will light. If people are out (no one in the bathroom) then the lights will turn off automatically (delay).


Hardware Requirement
  • Arduino Uno Board
  • HC-SR501 PIR Sensor
  • 1 Channel Relay Module
  • AC Lamp
  • LCD 16*2
  • Power supply +5 Volt
  • Jumper
PIR HC-SR501 Module | Source


Relay 1 Channel Module | Source            AC Lamp | Source


Block Diagram


Schematic



Arduino - PIR Sensor Wiring


Source Code/Sketch

#define PIR 7
#define Lampu 6
int flag_PIR = LOW;
void setup() {
pinMode(PIR, INPUT);
pinMode(Lampu,OUTPUT);
digitalWrite(Lampu,HIGH);
delay(3000);
}
void loop(){
if((digitalRead(PIR)==HIGH)&&(flag_PIR==LOW)){
flag_PIR = HIGH;
digitalWrite(Lampu,HIGH);//Lampu ON
}
else if ((digitalRead(PIR)==LOW)&&(flag_PIR == HIGH)){
flag_PIR = LOW;
digitalWrite(Lampu,LOW);//Lampu OFF
}
}

How it Works

1. Connect the Arduino with Peripherals needed.
2. Plug in the Power Source on the device.

3. Add some library if needed
4. Compile and upload the script program above to your arduino.
5. When the PIR sensor detects the movement (the person goes into the bathroom & moves) then the 
    relay will switch on and turn on the AC light. 
6. If there is no detectable person in the bathroom then the light will die after a few seconds delay.



Video for Project III - 16. Automatic Bathroom Lights with Pir Sensor based On Arduino





Required file

No comments:

Post a Comment