Rachana Jain
Published © Apache-2.0

How to Interface HC-SR501 PIR Sensor with Arduino

In this Arduino Tutorial, we will learn how to interface HC-SR501 PIR Sensor with the Arduino Board for detecting motion.  

BeginnerFull instructions provided2 hours82
How to Interface HC-SR501 PIR Sensor with Arduino

Things used in this project

Hardware components

Arduino UNO R3
×1
Alphanumeric LCD, 16 x 2
Alphanumeric LCD, 16 x 2
×1
Rotary Potentiometer, 10 kohm
Rotary Potentiometer, 10 kohm
×1
Resistor 220 ohm
Resistor 220 ohm
×1
PHPoC Bread Board
PHPoC Bread Board
×1
HC-SR501 PIR Sensor
×1
Connective Wires
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Circuit Diagram

Code

Arduino Code

C/C++
/*
How to Interface HC-SR501 PIR Sensor with Arduino
by www.playwithcircuit.com 
*/
#include <LiquidCrystal.h> // We are using JHD 16x2 alphanumeric LCD using HD44780 controller for its controller
LiquidCrystal lcd(12, 11, 6,7,8,9);
int sensorInput = 2;   // Output for PIR sensor input for controller
int sersorReturn=0;
void setup() {
  pinMode(sensorInput, INPUT);   // declare sensor pin as input pin
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // set the cursor to (column = 0,row = 0)
  lcd.setCursor(0, 0); 
  lcd.print("PIR Sensor Says:"); 
  // set the cursor to (column = 0,row = 1)
  lcd.setCursor(0, 1);  
}
void loop() {
  sersorReturn = digitalRead(sensorInput);  // read input value
  
  if(sersorReturn == HIGH)
  {
    // set the cursor to (column = 0,row = 1)
    lcd.setCursor(0, 1); 
    lcd.print("Motion Occurs"); 
  }
  else
  {
    // set the cursor to (column = 0,row = 1)
    lcd.setCursor(0, 1); 
    lcd.print("Motion Stops "); 
  }
}

Credits

Rachana Jain
13 projects • 8 followers
I'm an avid Arduino and electronics enthusiast with a passion for tinkering, experimenting, and bringing innovative ideas to life.

Comments