Home - Blog

HC SR501-How To Easily Controll House Lights

HC SR501-How To Easily Controll House Lights


This is a project about HC SR501 which wrote by an engineer who had ordered our boards.

Whether you are in a bathroom or in your study room, it makes life easier for you to automate the lighting system such that you do not have to switch every switch on. It is much more natural and enjoyable to let the lights behave the way you want, without having to get involved. For you to do a good job, you need to purchase some PCBs or instruct some PCB manufacturer (e.g. wellpcb.com) to do the job for you. In this tutorial, you shall use a couple Printed Circuit Boards, which can be termed as standard since they are used by almost all electronics enthusiasts and professionals.


These PCBs are as listed below:

 1.Arduino Nano Board

 2.HC SR501 PIR Sensor Module

 3.1 Channel 5V Controlled Relay Module

In addition to this, you will also need a 5V DC voltage source to power the Arduino and also a source of light; which is the normal bulb for your house lights.

To start with, we need to program our Arduino such that it is able to give the actuating signal whenever a human being makes some movement. The working sequence is simple. The PIR Sensor stays standby, waiting to detect any infrared signals registered from movement from a human being. When movement is registered and acknowledged by the Arduino, the Arduino issues a high signal to the relay module telling it to close contact for the light switch so that lights can go on since somebody is moving and needs some lighting. Where there is no movement recorded, lights go o . To keep this all working as it should, one has to include some timing in between the Arduino program to make sure that it waits for the right data and does not perform actions too quickly or based on erroneous data.

To get started, we shall start with a simple program using Arduino IDE. This program will be in control of our system. The program should be similar to the following:


lights using hc sr501 PIR Sensor PCB;


pir =

2; //PIR at pin




= 3; //Relay at

pin 3


1.void setup()

{Serial.begin(9600); pinMode(hc sr501 pir, INPUT); pinMode(relay, OUTPUT); digitalWrite(relay, LOW);delay(5*1000); //Wait for the PIR to settle}

Controlling House Lights Using HC SR501.png

2.Connect the power pin of the hc sr501 PIR Sensor board to the Arduino 5V and GND pin to Arduino ground pin.

The output pin of the sensor should be connected to the Arduino pin 2, according to the program. You could change this to suit your program. Note that in this when connecting, you may need male to female jumper wires. In most case, you leave all the other sensor settings the same as the factory settings. If for some reason, the sensor behaves in an undesirable or unexpected way, you can come back and increase the sensitivity or lower the delay time.

Controlling House Lights Using HC-SR501-1.png

3.The Arduino pin 3 should be connected to the IN pin of the 5V relay channel.

The 5V and the GND pins on the 1 channel relay should connected to 5V source and to the common ground respectively. The other side of the relay channel has Normally Open (NO) contacts and the Normally Closed (NC) contacts. We are going to use the NO contacts so that the ciruit shall be o even when the system is not powered. A house light bulb has a switch. This switch has two contact points. These two contact points come together to let the current ow and power the lights. Switch o the main switch and connect these two contacts to the NO contacts of the relay board. Note that this exercise could be very dangerous and should only be performed by or with the assistant of a responsible licensed electrician; unless you know what you are doing.

4.Having done all these connections right, power your circuit again.

Give the sensor sometime for it to settle. Now wave your hand infornt of the sensor for some time, then remove your hand and settle for some time. You should see lights go on when you wave your hand and go o when you remove your hand and settle. The project is complete! You can now go ahead and make a decent implementation of this prototype in your house.

Partner: Sam

Hi, I am Hommer, the founder of WellPCB. So far we have more than 4,000 customers worldwide. Any questions you can feel free to contact me. Thanks in advance.