Give your Uno a sense of “someone walked by.” The HC-SR501 watches for changes in invisible heat (infrared), then flips a digital pin HIGH — perfect for night lights, alarms, and hallway gadgets.
What you will learn
Hardware
White dome, three pins, two pots, one jumper.
How it works
Infrared change across two slots → OUT HIGH.
Arduino
Wire D8, light the onboard LED, print Serial.
Gotchas
Warm-up delay, lockout time, false triggers.
New to Uno? Finish Basic Arduino first. Coming from distance sensing? You already know digital pins from the Ultrasonic lesson.
What does PIR mean?
PIR = Passive Infrared. “Passive” means the module does not shine a beam at you — it only listens for infrared heat that warm bodies already give off. Walk past, the heat pattern in its view changes, and the electronics shout “motion!” on the OUT pin.
Security lights and automatic doors use the same idea. Your HC-SR501 is the hobby version: cheap, 5 V friendly, and happy on a breadboard.
Meet the HC-SR501
The white dome is a Fresnel lens — a plastic “megaphone” for infrared that spreads the view into many little detection zones. Under the dome sits a pyroelectric sensor with two slots. Behind the board: the BISS0001 controller chip, a small regulator (so you can feed roughly 5–12 V), two orange trim pots, and a tiny H/L jumper.
PCB (metal-can sensor) beside the Fresnel dome. The lens fans infrared into detection zones — see the diagram in “How a PIR sees you.”
Typical reach: about 3–7 m (sensitivity pot decides)
View angle: roughly 120°
OUT: digital HIGH when motion, LOW when idle
Current: usually under 2 mA — battery-friendly
Quick specs
Operating voltage
~4.5–20 V (5 V on Uno is perfect)
Current
< 2 mA typical
Output
TTL digital (HIGH ≈ 3.3 V on many boards)
Detection distance
~3–7 m (adjustable)
Detection angle
~120°
Time delay (OUT hold)
~1 s to ~3 min (adjustable)
Warm-up after power
~30–60 s
Module size
~32 × 24 mm (+ dome)
Pinout GNDOUTVCC
Only three pins. Learn them once — every PIR module of this family speaks the same language.
Common dome-side order: GND, OUT, VCC — always double-check the silkscreen on your module.
GND
Ground / 0 V. Share with the Uno’s GND.
OUT
Goes HIGH on motion, LOW when idle. Read with digitalRead().
VCC
Power. Uno 5V is ideal (module also accepts higher DC via its regulator).
How a PIR “sees” you
Think of two tiny thermometers side by side. A still room looks the same to both. When a warm person slides across the view, one slot heats before the other — that difference is the motion clue. The BISS0001 chip cleans the signal and drives OUT.
Side beams hit the floor in layers; the top fan shows near / mid / far zones. Walking across the beams (not straight at the sensor) is the ideal trigger direction.
Inside each zone: Fresnel lens → focused IR → slots A/B differ → digital HIGH on OUT.
Lens: splits the room into many detection zones.
Motion: your heat crosses zones in sequence.
Chip: turns the differential blip into a clean pulse on OUT.
Hold time: OUT stays HIGH for the delay set by the time pot (and jumper mode).
Try it: walk-by demo
Press Walk — the demo pretends a person crossing the view. Watch OUT flip HIGH, then settle LOW after the hold time.
OUT = LOW
Idle room — press Walk past.
Knobs & jumper
Flip the module over. Two orange pots and a three-pin jumper control behaviour.
Sensitivity: farther reach vs fewer false triggers.
Time delay: how long OUT stays HIGH (~1 s … ~3 min).
Jumper L (single): one pulse, then the module ignores new motion until the delay finishes.
Jumper H (repeat): keeps extending HIGH while motion continues.
Optional pads: some boards leave spots for a thermistor (temperature tweak) and an LDR (day/night). Leave them empty unless your project needs them.
Standalone test (no Arduino yet)
Want to trust the module first? Power VCC/GND from 5–12 V and put an LED (+ 220 Ω) from OUT to GND. Wave your hand — LED lights when OUT is HIGH. That proves the sensor before you blame the sketch.
Wiring to Arduino Uno
Three wires. That is the whole story for a digital motion input.
Suggested pin for this lesson: OUT → D8. You may choose another digital pin if you update the sketch.
HC-SR501
Arduino Uno
VCC
5V
GND
GND
OUT
Digital pin 8
Safety habit: unplug USB before rearranging jumpers. Never short 5V to GND.
Example sketch — LED + Serial
Upload this, open Tools → Serial Monitor at 9600 baud, wait for warm-up, then walk past the dome. Onboard LED (D13) mirrors motion.
// HC-SR501 PIR — LED + Serial on motion edgesconst int ledPin = 13; // onboard LEDconst int pirPin = 8; // OUT → D8int pirState = LOW; // last known motion stateint val = 0;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(pirPin, INPUT);
Serial.begin(9600);
Serial.println("PIR warming up — wait ~30-60 s");
}
void loop() {
val = digitalRead(pirPin);
if (val == HIGH) {
digitalWrite(ledPin, HIGH);
if (pirState == LOW) {
Serial.println("Motion detected!");
pirState = HIGH;
}
} else {
digitalWrite(ledPin, LOW);
if (pirState == HIGH) {
Serial.println("Motion ended!");
pirState = LOW;
}
}
}
What the code is doing
pirPin = 8 — must match your OUT wire.
digitalRead(pirPin) — HIGH means the module currently reports motion (or is still in hold time).
pirState — remembers the previous edge so Serial only prints when something changes.
No library required — plain digital input.
Design tips — lockout & warm-up
Power-on delay: after plugging in, wait 30–60 seconds while the sensor learns the room. The LED may blink oddly — that is normal.
Lockout: when OUT falls LOW, many modules stay “deaf” for about 2 seconds before the next trigger. Build that pause into timers and alarms.
Aim carefully: point at walkways, not heaters, sunny windows, or fluttering curtains.
Pets & fans: turn sensitivity down if cats or warm air currents spam the Serial Monitor.
In one sentence: warm body crosses the Fresnel view → slots disagree → OUT goes HIGH for the time you set — Arduino just reads a digital pin.