11. PIR sensor: only when someone is there
Step 11 of the automatic light: Q2 goes in series below Q1, its base driven by the PIR output. Now both must be on: dark (Q1) AND movement (Q2). The lamp lights only when someone walks by at night. Component 11 of 14: the pir motion sensor. A passive infrared sensor sees the heat of a moving body. The HC-SR501 module does all the work and gives a logic output: 3.3 V for a few seconds after it sees movement, 0 V otherwise. It runs on 4.5–20 V and needs about a minute to settle at power-up (shortened in the lab).

Build it in the labGuided build, test sheet and fault finding, free in your browser.
Parts list
- DC adapter
- Schottky diode
- Toggle switch
- Electrolytic capacitor
- 6 × Resistor
- LED
- 7805 regulator
- 2 × Ceramic capacitor
- Photoresistor (LDR)
- 2 × NPN transistor
- LM339 quad comparator
- Potentiometer
- PIR motion sensor
- Relay
- Rectifier diode
- 12 V DC LED bulb
Test procedure
Each test has an expected value and a pass range, like a factory test sheet:
- Dark, nobody there: lamp off
- Dark and movement: lamp on
- Daylight and movement: lamp off
How it works
The pir motion sensor. A passive infrared sensor sees the heat of a moving body. The HC-SR501 module does all the work and gives a logic output: 3.3 V for a few seconds after it sees movement, 0 V otherwise. It runs on 4.5–20 V and needs about a minute to settle at power-up (shortened in the lab).
Reading it. Three pins: VCC, OUT, GND (printed under the dome). Two trimmers: sensitivity (range) and hold time; a jumper sets single or repeat trigger.
Testing it. Power it, wait a minute, wave a hand: OUT goes to about 3.3 V and drops back after the hold time. A meter or an LED with 1 k on OUT shows it.
In the build. Q2 goes in series below Q1, its base driven by the PIR output. Now both must be on: dark (Q1) AND movement (Q2). The lamp lights only when someone walks by at night.
Builds on lesson 10: everything from before is still there.
Next: lesson 12, 555 timer.
Things to try
- Click the PIR to make movement (after its 2 s warm-up).
- Make it bright and click the PIR: nothing happens. That is the AND.
Background
One circuit, built up one part at a time: by lesson 14 it is a solar-powered, dusk-sensing, motion-triggered timed lamp with an alarm.