Skip to content

PIR Motion Detector

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

PIR Motion Detector: the matching Arduino Uno circuit rendered in Circuitera’s simulator
Matching Circuitera simulator circuit. Real firmware capture; modeled components are idealized.

Wire it up

Disconnect power before changing connections. Follow terminal names rather than wire colors.

FromToWhy it matters
HC-SR501 PIR (sensor1) · VCCUno · 5VPower connection
HC-SR501 PIR (sensor1) · GNDUno · GND.2Ground reference
HC-SR501 PIR (sensor1) · OUTUno · 2Match this terminal to the sketch

The complete sketch

pir-motion.ino
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

  1. 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.

  2. Explore the live circuit

    Set the PIR level to 1 and then 0 in Component Properties; watch Motion change to Clear.

  3. 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.

Keep exploring.