DIY Project: Automatic Electronic Device Control System using PIR Sensor and PIC Microcontroller.

Project by


Coming is the era of smart home, where everything is automated.  Now here comes a DIY project to help you literally search in the dark. How?   

This is a small electronic DIY project. This DIY project as the name suggests is an automatic light controlling system. The automatic in the sense this system will be triggered on and off by an external signal. Here the external signal is the movement made by the human. As the presence of human is felt in the PIR sensor, it will trigger on the device. After a certain delay it will off the system if no presence is felt or a second impulse is not sent to the PIR sensor.

So leave behind the tension of forgetting switching off lights or searching the light panel to on the lights. Now let’s start the procedure for developing this DIY project. First, components required to build this DIY project. 


Components required

  1. Relay
  2. PIR sensor
  3. PIC Microcontroller
  4. LDR

We will have a small brief about all these components.

PIR sensor

PIR sensor stands for Passive Infrared sensor. PIR sensor measures the IR radiated from the object in its vicinity. In general every object emits heat and it will be in IR range. PIR sensor is called passive because no energy is generated by the device for its working. Here in this DIY project the PIR sensor detects the IR emitted by the human.

The PIR sensor in use is SB0061 PIR sensor module. It is a pyroelectric sensor module.  Pyroelectric means it produce voltage when the material undergoes a temperature variation. It has a fresnel lens mounted over it. This PIR sensor will detect only the movement of human body. It has two potentiometers for sensitivity and for response time. These potentiometers of PIR sensor must be set in high position for quick response and to make the time period high to make the device stay on.  The voltage required for its working is 5-20V and it can be designed to work in the range of 3-24 V.

PIC Microcontroller

PIC Microcontroller is the controlling unit in this DIY project or it can be said as the heart of the entire project.  The PIC Microcontroller used here is PIC16F883A. It is a 28 pin 8 bit Microchip Microcontroller. It requires 5V for its working.  PIC Microcontroller has an inbuilt timer which can be programmed as per the requirement. 


Relay is nothing but a simple switch which is operated electrically. Relay used in this DIY project is 12V SPDT one. SPDT stands for Single Pole Double Throw.  It has 5 connections. The first 2 are for the power supply. The other 3 are NO (Normally Open), NC (Normally Close) and COM (Common).


LDR or light dependent resistor act as a light sensor. When the light falls on the photoresistor the resistance decreases and current passes through the circuit.

Block Diagram for the DIY project

Block diagram

Circuit Diagram

circuit diagram

                                                 Circuit Diagram of the DIY Project

PCB and Component Layout

PCB layout

              PCB layout 


The components are connected as per the diagram and the PIC Microcontroller is programmed. The programming is done to make the internal timer switch the relay on and off for the specific time period. The board will be connected to the device which you want to control automatically. Here we can control with the switch board. Initially consider the device in off state.

As we know a PIR sensor has 2 slots in it. The 2 slots are sensitive to IR. At off state, it will detect equal amount of IR rays from both the slits. When a person enters the room and it passes the PIR range, an intercept will be detected in one of the slot as the amount of radiation detected will vary. As a result a positive differential change will occur in the sensor. This signal will be given to the digital input pin of the PIC Microcontroller. Upon receiving the signal, the CPU of our DIY project i.e.PIC Microcontroller goes to the ‘on’ state.

The PIC Microcontroller is programmed in such a way that when a digital input signal is received, the internal timer will goes to the ‘on’ state. The time period it will be in ‘on’ state will be given by the user as per the requirement while programming. The digital output of the PIC Microcontroller is connected to the relay.

When an output is detected at the relay, a voltage will be applied across its terminals. The current flow will energize the electromagnetic field thus inducing a strong magnetic field. This will make the 'NO' to go into closed position. This will complete the circuit and will make the device to go into on state.  As a result lights & fans will get on. Now there is a provision for activating the LDR which will make the light to get on only when the light intensity is feeble. This will help to save the energy.

The device will be in on state for a fraction of minutes only. If the PIC Microcontroller doesn’t get the second interrupt, the positive differential signal from the PIR sensor, the relay will go into off state. This happens when the PIR sensor can’t detect any movement and this may arise by either the person has left the room or he is in idle position.  In turn, no digital input will be given to the PIC Microcontroller to drive the relay.  The device will go into off state.   


Hope you guys will try this project. This will be useful to save electricity as the device will be in on and off state depends only on the human movement. Thus saves the energy………………

User Review (0)
Related Items