← BACK TO THE SIMPLE VERSION
PROPER INSTRUCTIONS

Build a motion detector: proper instructions

A passive infrared (PIR) module can illuminate an LED when a warm moving body crosses its sensing zones. This is a learning project or a non-critical light trigger. PIR detects changing infrared patterns; it does not identify a person, measure distance accurately or provide security-grade detection.

Parts and wiring

  1. With power removed, connect PIR VCC to 5 V, GND to GND and OUT to D2. Read the printed labels because clone connector order differs.
  2. Connect LED anode through its resistor to D13 and cathode to GND.
  3. Select the module’s repeat mode, set sensitivity and hold-time low, and point the white lens at the desired area.

Software

Set D2 as INPUT and D13 as OUTPUT. Read D2 roughly every 50 milliseconds and copy HIGH or LOW to the LED. Print only changes to Serial Monitor at 9600 baud. Add a 30-second delay in setup, because a PIR needs a warm-up period after power-up.

read PIR; light LED when HIGH; print “Motion detected” on LOW-to-HIGH change; print “Area clear” on HIGH-to-LOW change.

Test and placement

  1. Power it and wait still through warm-up.
  2. Walk across the field of view at normal pace; crossing zones works better than walking directly towards the dome.
  3. Wait for the LED to clear, then adjust delay only if necessary. Adjust sensitivity one control movement at a time.
  4. Try sunlight, heating airflow, fans, curtains and pets before choosing a final location.

Common faults

Symptom Likely cause
Always HIGH Warm-up, long hold time, repeat mode, or changing heat source.
Never detects Wrong VCC/GND/OUT order, low sensitivity or unsuitable approach direction.
Random triggers Sun, radiator, fan, pet, curtain or loose power.
Fails after mounting Glass blocks infrared, the lens is masked, or it points at the wrong height.

Security limitations

A still person may not trigger it; a pet or warm draught may. It has blind spots, can be covered and stops when USB power is removed. An LED and serial message are not an alarm response. Do not covertly monitor people or rely on this to protect property or people. Real premises security needs designed sensors, protected power, tamper detection and appropriate lawful notification.

Build carefully

Disconnect USB before moving wires. Work on a dry, uncluttered bench and use only the low-voltage supply provided by USB while developing the circuit. Check each connection against the label on the actual module, because clone boards can put connectors in a different order. A breadboard is useful for experiments but its contacts can work loose; do not leave an unattended project in a place where a lead can be pulled, crushed or exposed to water.

Record what you changed between tests. Change one setting, upload one revision, then repeat the same test. This is faster and safer than changing wiring, code and sensor position at once. Once the circuit works, add strain relief and an enclosure, but keep access for inspection and do not hide untested connections.

Before relying on any result

Repeat the test after changing the final location and after a power cycle. Label leads and keep notes of settings, dates and observed behaviour. Do not extend sensor leads indefinitely or substitute a power supply without checking voltage and current requirements. If behaviour changes without an explained reason, return to the last known-good wiring rather than bypassing a protective component or increasing supply voltage.

Review the result

Hobby electronics is most reliable when its assumptions are visible. Identify what creates an input, what the board decides, and what physical output follows. Consider loss of power, disconnected cable, loose breadboard contact, wrong software port, restart, accidental adjustment and environmental change. A successful five-minute demonstration proves only that it worked for five minutes under those conditions. Repeat tests after adjustments, and keep the project clearly labelled as a low-voltage experiment where others might otherwise assume it provides protection or control.

Practical checklist

Before each use, inspect the USB lead, board, insulation and sensor cable for damage. Confirm the board is powered from the intended low-voltage source and that its indicator behaviour agrees with the latest test. Keep the instructions, component part numbers and the current program with the project so that a future repair does not depend on memory. Do not leave a breadboard assembly where children, pets, moisture, metal objects or moving furniture can reach it. Disconnect power before repositioning conductors.

When diagnosing a problem, begin with the simplest observation: power indication, physical connector orientation, measured input state and program output. Use a known-good cable and a short test setup before adding extensions, enclosures or optional modules. Do not “fix” an uncertain fault by removing resistors, joining supply rails, increasing voltage or bypassing a switch. If a component becomes hot, smells unusual, repeatedly resets the board, or has damaged insulation, disconnect power and replace or investigate it before continuing.

Document both expected and unexpected results. Note the ambient conditions, sensor placement, delay settings and test duration. That evidence makes false triggers, questionable temperature readings and intermittent connections easier to distinguish from software mistakes. The finished device remains a hobby experiment: use independent, purpose-designed equipment wherever a missed event, incorrect measurement or failure to operate could cause loss, injury, regulatory breach or an emergency response.