PIR Motion Detector
Read a PIR module’s digital motion output and report its state over serial.

Wire it up
Disconnect power before changing connections. Follow terminal names rather than wire colors.
| From | To | Why it matters |
|---|---|---|
| HC-SR501 PIR (sensor1) · VCC | Uno · 5V | Power connection |
| HC-SR501 PIR (sensor1) · GND | Uno · GND.2 | Ground reference |
| HC-SR501 PIR (sensor1) · OUT | Uno · 2 | Match this terminal to the sketch |
The complete sketch
void setup() { Serial.begin(9600); pinMode(2, INPUT); }
void loop() {
Serial.println(digitalRead(2) ? "Motion" : "Clear");
delay(250);
}
The launch buttons use this same code and a matching saved circuit.
Build it step by step
Open a complete project
Launch in Simulator creates a separate Uno sketch and its matching wired circuit. Existing sketches are preserved. Press Run to compile and execute.
Explore the live circuit
Set the PIR level to 1 and then 0 in Component Properties; watch Motion change to Clear.
Try it on hardware
Disconnect power while wiring. Match terminal names in the table, select the exact board, Verify, then connect and upload. Check component ratings and power requirements first.
Understand the sketch
A digital event, not a distance
The PIR output only reports a motion state. The simulator uses the editable level property; it does not reproduce the physical sensor’s warm-up time, delay, or retrigger behavior.
If something is different
Real sensor behaves differently
Allow the physical sensor to warm up and check its delay/retrigger settings and exact pinout.
Expected output and tested scope
Serial output changes from Clear to Motion when the modeled PIR output becomes active.
Version 1 · Last source- and build-matched test: 2026-10-25. Actual shipped AVR-GCC WASM compilation and Uno AVR engine execution; no physical hardware test.
Supported tutorial target: Arduino Uno R3 / ATmega328P. Compile: PASS · Modeled execution: PASS. Other boards require a separate review of pins, voltage, libraries and the exact build profile.