Lesson – 12: Interfacing HC-SR501 PIR Motion Sensor with Arduino
921 views on YouTube
Lesson – 12: Interfacing HC-SR501 PIR Motion Sensor with Arduino
Hello and welcome to Electro Nerds Academy. In this tutorial, we’ll learn how to interface the HC-SR501 PIR sensor with Arduino and use it to build a simple motion-controlled light project.
The PIR (Passive Infrared) sensor detects motion by sensing infrared radiation emitted by warm objects like humans and animals. It’s widely used in motion detectors, automatic lighting systems, home security alarms, and IoT projects.
In this video, you’ll learn:
✅ How the HC-SR501 PIR sensor works
✅ What are pyroelectric sensors, Fresnel lenses, and on board electronics
✅ How to adjust sensitivity and time delay using onboard potentiometers.
✅ The difference between single trigger and multiple trigger modes.
✅ Step-by-step circuit connections with Arduino and a relay module.
✅ Writing and uploading the Arduino code to control a household light bulb with motion detection.
Code used in this video:
// HC-SR501 PIR Motion Sensor with Arduino and Relay
// Electro Nerds Academy
int RELAY = 5; // Relay control pin
int SENSOR = 4; // PIR sensor output pin
int value = 0; // PIR sensor value
void setup()
{
pinMode(RELAY, OUTPUT); // Relay pin as output
pinMode(SENSOR, INPUT); // PIR sensor pin as input
delay(40000); // 40 seconds for PIR sensor calibration
}
void loop()
{
value = digitalRead(SENSOR); // Read PIR sensor
if (value == 1)
{ // Motion detected
digitalWrite(RELAY, LOW); // Turn ON relay (active LOW)
delay(100);
}
if (value == 0)
{ // No motion
digitalWrite(RELAY, HIGH); // Turn OFF relay
delay(100);
}
}
⚡ Warning: This project involves working with AC mains voltage when connecting the light bulb to the relay. Please take proper safety precautions. And we are not responsible for any damage done.
By the end of this video, you’ll be able to create your own motion-activated light system using Arduino and the HC-SR501 PIR sensor.
If you found this helpful, don’t forget to Like 👍, Share and Subscribe 🔔 to Electro Nerds Academy for more Arduino and electronics tutorials like this!
#HCSR501 #pirsensor #ArduinoProjects #ElectronicsDIY #arduino #arduinotutorials #embeddedsystems #electronicsforbeginners #electronerdsacademy #arduinotutorials #ElectronicsForBeginners #arduinoprogramming #circuitbuilding