PIR Motion Sensor (HC-SR501)

A Passive Infrared (PIR) sensor detects motion by measuring changes in the infrared radiation (heat) emitted by surrounding objects (such as humans or animals) moving across its field of view.

Sensors9 blocksMicroPythonC++
PIR Sensor

At a glance

Pins and properties exactly as the circuit editor and simulator define this part. The text below explains how to use them.

Pinout

Pinout of the PIR Sensor, drawn as in the circuit editor. Select a label to see that pin in the table below.

Pins

Pins of this part
PinLabelType
GNDGNDGround
OUTOUTSignal out
VCCVCCPower in

Properties

What you can change in the Property Inspector.

Properties of this part
PropertyRange or choicesDefault
Sensitivity0 to 1023512
Time Delay0.3 to 60 s5 s
Repeat TriggerSingle, RepeatSingle

A Passive Infrared (PIR) sensor detects motion by measuring changes in the infrared radiation (heat) emitted by surrounding objects (such as humans or animals) moving across its field of view. In Open Maker Studio, the PIR sensor is the primary module for security systems, occupancy detection, and motion-activated devices.


1. Hardware Specifications & Pinout

  • Operating Voltage: Real HC-SR501 module accepts 5–20V VCC — an onboard LDO regulates the OUT pin's HIGH level to a fixed 3.3V regardless of input voltage (confirmed via a real HC-SR501 datasheet citation in the component's own code).
  • Output Signal: 3.3V digital logic (HIGH = motion detected, LOW = clear/idle).
  • Detection Angle & Range: 110° cone (confirmed exactly), from 0.3m to 7m depending on the Sensitivity setting.
  • Onboard Adjustment Potentiometers:
    • Sensitivity (SENS): Adjusts the detection range from 0.3m to 7m.
    • Delay Time (TIME): Adjusts how long the output stays HIGH after motion stops, from 0.3s to 60s.
  • Pin Configuration:
    • VCC: Connect to power (5–20V real range; simulated here).
    • GND: Connect to common Ground.
    • OUT: Connect to any digital input pin (supporting external interrupts for instant triggers).

2. How it Works (Theory of Operation)

The PIR sensor contains a pyroelectric sensor chip split into two halves behind a Fresnel lens.

  • Ambient Calibration: When powered on, the sensor needs up to 60 seconds to sample the background infrared profile of the room.
  • Motion Detection: When a warm body moves in front of the sensor, it first cuts one half of the sensor and then the other. The differential change in IR voltage triggers the internal comparator, driving the OUT pin HIGH.
  • Trigger Modes: A yellow jumper on the back selects between:
    • Single Trigger (L) — the real OMS default: Output goes HIGH on motion, stays HIGH for the set delay, then goes LOW, even if motion continues (re-entering the detection zone while the delay timer is counting does NOT reset it).
    • Repeat Trigger (H): Stays HIGH as long as motion persists — re-entering the zone while the delay timer is counting cancels and restarts it.

3. Component Properties (Property Inspector)

When you select the PIR Sensor on the canvas, you can modify the following parameters in the Property Inspector panel:

  • Sensitivity (sensitivity): Sets the detection range.
    • Default: 512
    • Range: 0 to 1023 (maps to 0.3m–7m of real detection distance)
  • Time Delay (timeDelay): How long OUT stays HIGH after motion stops.
    • Default: 5 s
    • Range: 0.3 s to 60 s (step size 0.1 s)
  • Repeat Trigger (repeatTrigger): Selects Single vs. Repeat trigger mode.
    • Default: Single (0) — not Repeat.
    • Options: Single (0), Repeat (1)

Motion itself isn't a simple on/off toggle — see Section 6, since the real interaction is a draggable person figure with genuine distance/angle geometry, not a checkbox.


4. Supported Blockly Blocks

Drawing the blocks…

5. Simulator Behavior

  • Drag the Person, Not a Checkbox: OMS models this with a genuinely geometric detection simulation, not a simple motion toggle — drag the person figure drawn on the canvas into or out of the visible 110° detection cone. Real distance/angle math (from the sensor's origin) decides whether you're actually "in range," using the Sensitivity-derived max range (0.3m–7m).
  • Trigger Timer Logic: Entering the cone drives OUT HIGH immediately. Leaving it starts the Time Delay countdown; in Repeat mode, re-entering while that countdown is running cancels and restarts it, while in Single mode (the real default) re-entering has no effect on the already-running countdown — matching the real jumper behavior from Section 2.
  • Mode Indicator LED: The onboard motion LED's color reflects the current trigger mode (an orange tone for Repeat, a yellow-gold tone for Single) as a quick visual reminder of which mode is active.
PIR Motion Sensor (HC-SR501) — OMS Parts