Project tutorial
PIR Sensor Integration

PIR Sensor Integration © GPL3+

Detect movement up to 30' away which is useful in motion-activated projects such as a security system or automatic lighting in a classroom.

  • 5 respects

Components and supplies

Necessary tools and machines

Apps and online services

About this project


In this project, we’ll be replacing the DHT11 temperature and humidity sensor from Project 10 with a Passive InfraRed (PIR) sensor. The PIR sensor can detect movement up to 30′ away at 180 degrees. This can be useful in motion-activated projects such as a security system or automatic lighting in an office or classroom.

16x2 Character LCD

Please see our project "Interface a 16x2 Character LCD" on how to interface the 16×2 LCD in 4-bit mode. You should have pins 4, 6, and 11-14 of the LCD connected to Uno pins 2, 3, and 4-7, respectively. The LCD is mounted to the Modulus Canister via the 16-pin, right-angle female header soldered to the 1-to-1 link, as shown in the image below.

You can also connect the LCD to a solderless breadboard, as shown in the image below.

Passive InfraRed (PIR) Sensor

The PIR sensor that we are using consists of 4 pins: GND, VCC, OUT, and EN. It can measure movement up to 30′ away which can be adjusted with the potentiometer on the module. Within the dome-shaped lens (used to focus the incoming light onto the detectors), there are two slots that can detect different levels of infrared (IR) light or radiation. The sensor does not detect motion when the detectors sense the same amount of IR. The motion is detected when the detectors measure two different levels of IR. The levels of IR can vary from object to object since each one emits different amounts of heat energy.

A table is shown below that outlines the specifications for the PIR sensor that we are using. The datasheet is also available here.

If you completed our previous project "Displaying Temperature and Humidity on an LCD", remove the DHT11 sensor and insert the PIR sensor. You should have the 4-pin R/A female header soldered to Modulus. There should also be a 4-pin single-row male header soldered adjacently to the R/A female header. This is used so we can wire-wrap. You have to create a solder bridge between each contact to connect the respective pins on the female header to the male header.

Once the headers are soldered on, plug the Modulus Canister into the 4×26-pin connector on the FuelCan, and insert the PIR sensor as shown below. Using the image below as reference, wire-wrap the leftmost pin of the male header to the GND vector on Modulus and the second pin from the left to +5Vdc on the 4×26-pin breakout. The third and fourth pins from the left are OUT and EN, respectively. Use a 12″ F/M to route the OUT pin to pin 8 on the Uno, and the EN pin to pin 9 on the Uno.

If you are using a solderless breadboard, the wiring schematic is shown below.

FuelCan Wiring

If you haven’t mounted the Uno onto the prototyping area of the FuelCan, go ahead and do that. If you are using a breadboard instead of Modulus, place the breadboard in the bottom storage compartment to limit the length of the jumper wires. You’ll need to supply +5V and GND to the power and ground rails on the breadboard by using the provided banana jack to test-lead clip cables. You will need two male header pins to mount the test-lead clips on the breadboard side. Plug the Type A side of the USB cable into USB1 receptacle and the Type B side into the Uno’s receptacle, so we can power and program the Uno. Power up the FuelCan with the AC-DC power adapter.


Once the wiring is complete and the FuelCan is powered up, we can now load the sketch onto the Uno. The sketch is below. The PIR sensor is enabled in void setup (). In void loop (), the OUT pin from the sensor is polled – if the pin goes HIGH, “Motion detected” is displayed on the LCD. If the OUT pin is LOW, “No motion” is displayed on the LCD.

There is a nomotionflag within the sketch which limits the amount of times we write to the LCD. For example, if the flag equals zero, we display “No motion” on the LCD. Once it is displayed, the flag gets set to one and it will not keep writing “No motion” if no movement is detected. When movement is detected, the flag gets reset to zero, and “Motion detected” is displayed on the LCD.

**Disclosure: Please note that this content uses affiliate links in which ProteShea may receive a commission. Please do not purchase these products unless they will help you with your own projects.


PIR Sensor IntegrationArduino
//Interface a PIR sensor to detect motion and display "Motion detected" or
//"No motion" depending on the output from the sensor

#include <LiquidCrystal.h>

//variable declarations
uint8_t readPIR = 0;
uint8_t nomotionflag = 0;
const int RS = 2, EN = 3, D4 = 4, D5 = 5, D6 = 6, D7 = 7;

LiquidCrystal lcd(RS,EN,D4,D5,D6,D7);   //set Uno pins that are connected to LCD, 4-bit mode

void setup() {
  lcd.begin(16,2);          //set 16 columns and 2 rows of 16x2 LCD
  pinMode(8, INPUT);        //output of PIR sensor (input to Uno)
  pinMode(9, OUTPUT);       //input to PIR sensor to enable (output of Uno)
  digitalWrite(9, HIGH);    //enable PIR sensor


void loop() {
  readPIR = digitalRead(8);   //check if motion detected
  if (readPIR == 1){          //motion detected
    nomotionflag = 0;         //reset flag
    lcd.print("Motion Detected");

  else{                         //no motion detected
    if (nomotionflag == 0){       
      lcd.print("No motion");
      nomotionflag = 1;


Final Circuit Schematic
Circuit schematic p11 dotgmfzevi


Similar projects you might like

PIR Sensor Tutorial - With Or Out Arduino

by Tarantula3

  • 35 respects


Project tutorial by DIY Partners

  • 44 respects

Touch Sensor and Sound Sensor Controlling AC/DC Lights

Project showcase by Anbumachi

  • 7 respects

RobotGeek PIR Motion Sensor Night Light

Project tutorial by Team RobotGeek Projects Team

  • 1 comment
  • 6 respects

Easy Motion and Gesture Detection by PIR Sensor & Arduino

Project tutorial by ElectroPeak

  • 302 respects
Add projectSign up / Login