Motion light
A PIR module, a transistor and a lamp, no board. Click the dome and the light holds for two seconds after the movement stops. There is no microcontroller in it: the simulator solves the 5 parts as a circuit, so it runs the moment you press Run, and nothing needs compiling.
BeginnerRuns in your browser. Free, and no account needed.
Step by step, with the wiring and the common mistakes: PIR Motion Sensor: How It Works, With an Arduino
How it works
There is no microcontroller in this one, so nothing is compiled: the simulator solves the circuit itself. The file in the editor is the notes that come with it.
// A motion light with no board: a PIR, a transistor and a lamp.
//
// Nothing here is programmed. The HC-SR501 module has its own chip on it, and
// what comes out of OUT is already a clean digital signal: high while it can
// see movement, and for the hold time afterwards.
//
// PIR VCC -> 5 V, GND -> ground
// PIR OUT -> 1 k -> the base of a 2N2222
// emitter -> ground, collector -> the lamp -> 220 ohm -> 5 V
//
// The output is 3.3 V and not 5, whatever the module is powered from, because
// the regulator on the board feeds its logic. Through 1 k into a base that is
// a good two and a half milliamps, and a 2N2222 with a gain of a hundred will
// pass far more than the lamp's twelve.
//
// Things to try. Click the dome, then click it again and count: the lamp holds
// for two seconds. Now click again right away: nothing, for another two
// and a half, because the module ignores everything after a pulse. Then open
// the PIR's properties and set retrigger to single: now holding the movement
// on gives one pulse and no more.
Parts list
7 parts, plus the jumper wires. Every one is in the editor's parts bin.
- 1 × Half breadboard
- 1 × Power, 5 V
- 1 × Motion sensor
- 1 × Transistor (NPN or PNP)
- 1 × Resistor, 1k Ω
- 1 × LED, yellow
- 1 × Resistor, 220 Ω
How it is wired
6 connections, pin by pin, read from the circuit itself. Each line is one set of pins joined together, by a jumper wire or a breadboard strip.
- 5 V: Motion sensor pin VCC; Resistor, 220 Ω pin 2
- Ground: Motion sensor pin GND; Transistor (NPN or PNP) pin E
- Motion sensor pin OUT; Resistor, 1k Ω pin 1
- Transistor (NPN or PNP) pin C; LED, yellow pin C
- Transistor (NPN or PNP) pin B; Resistor, 1k Ω pin 2
- LED, yellow pin A; Resistor, 220 Ω pin 1
Change it and keep it
Open it in the editor, change the circuit or the code, and keep your version in a free account.