HC-SR501 PIR Motion Sensor Explained: How It Works and How to Wire It to an Arduino Uno

The HC-SR501 is a passive infrared (PIR) motion sensor module that detects movement by sensing changes in infrared radiation — the heat given off by a warm body — passing through its field of view. It does not emit any signal of its own; it only watches for changes in the infrared energy already present in the room. The module has three pins (VCC, OUT, GND), accepts a wide 4.5–20V DC input, and outputs a clean 3.3V digital HIGH when motion is detected and LOW when it isn't, which makes it safe to wire directly into both 5V boards like the Arduino Uno and 3.3V boards like the ESP32 without a level shifter.

How does the HC-SR501 detect motion?

Inside the white dome lens sits a pyroelectric sensor element that generates a small voltage whenever the infrared energy hitting it changes. The Fresnel lens on top splits the sensor's view into multiple zones, so a warm object — a person walking through the room — crosses zone boundaries as it moves and creates a changing IR signal rather than a flat, constant one. An empty room radiates heat too, but that signal stays steady, so the onboard comparator circuit ignores it. Only a change in infrared level flips the OUT pin from LOW to HIGH. This is why the sensor is called passive: it senses, it doesn't transmit anything to bounce back, unlike an ultrasonic or active-IR distance sensor.

What do the two potentiometers and the trigger jumper do?

The HC-SR501 has two onboard trimmer potentiometers and a small 3-pin jumper, all adjustable without any code:

Control What it adjusts Typical range
Sensitivity potentiometer How far away a moving body can be and still trigger a detection roughly 3–7 meters
Delay (time) potentiometer How long OUT stays HIGH after the most recent detection roughly 5 seconds to several minutes
Trigger-mode jumper Single trigger: one HIGH pulse per detection, ignores further motion until it goes LOW. Repeatable trigger: OUT stays HIGH continuously as long as motion keeps being detected jumper position, not a potentiometer

Repeatable trigger is the common default and the more useful setting for alarms and lighting, since it keeps the output HIGH the whole time someone is actually present rather than timing out mid-motion. The detection cone itself is fixed by the lens, roughly 110–120 degrees.

How do you wire the HC-SR501 to an Arduino Uno?

Arduino Uno pin HC-SR501 pin Signal
5V VCC power
GND GND ground
Digital Pin 2 OUT motion signal (HIGH/LOW)

Three wires, no resistors and no level shifting needed — the OUT pin's 3.3V HIGH reads reliably as a logic HIGH on the Uno's 5V-logic input pins. Reading the sensor in firmware is just a single digitalRead() call on whichever digital pin OUT is connected to; no library is required for basic motion detection.

Why does my HC-SR501 give false triggers right after power-on?

The sensor needs a warm-up or stabilization period of roughly 30–60 seconds after power is applied before its readings settle down. During that window the pyroelectric element is still adjusting to the ambient infrared level in the room, and it commonly reports phantom motion or holds OUT high on its own. This is the single most common beginner mistake with the HC-SR501 — testing it, or judging it faulty, in the first few seconds after plugging it in. Give it the full warm-up window, keep it away from direct sunlight, moving curtains, and HVAC vents (all of which change infrared levels without any motion), and false triggers mostly disappear.

Watch it built live: a real Arduino Uno + HC-SR501 project

Rather than describe a generic build, we typed one real sentence into Compoden's AI build assistant on the storefront and let it do the part-picking, pricing, and explaining — unscripted, screenshotted as it happened:

"I want to build a motion-activated alarm project using an HC-SR501 PIR sensor and an Arduino Uno"

Compoden AI build assistant screenshot: HC-SR501 motion-activated alarm build with parts tray

It picked seven in-stock parts — sensor, microcontroller, an active buzzer for the audible alarm, an LED for the visual alert, plus breadboard wiring and power — and explained the reasoning for each. It also flagged the one real risk unprompted: "the HC-SR501 PIR sensor outputs 3.3V logic, but the Arduino Uno operates at 5V logic. While the Arduino Uno can often read 3.3V signals as high, it's a potential point of failure if the signal is too weak," which matches why the wiring table above routes OUT straight to a digital pin with no extra components.

Watch the firmware get generated

We then asked Compoden's build companion, Soldr, to write the actual Arduino sketch for the same project — real pin definitions, targeting the Uno specifically:

Soldr.dev firmware editor screenshot: generated Arduino code for the HC-SR501 motion alarm project

The generated sketch defines PIR_SENSOR_PIN on Digital Pin 2 with a comment identifying it as the HC-SR501's data pin, BUZZER_PIN on Digital Pin 3 for the active buzzer, and LED_PIN on Digital Pin 4 for the visual indicator — matching the wiring table above exactly. No motion-sensor library is pulled in, consistent with the sensor needing nothing more than a digital read. It's editable in place and compiles against other board targets beyond the Uno as well.

So what is the HC-SR501 actually good for?

Anything that needs to react to a person or animal entering an area: motion-activated lighting, security and burglar alarms, automatic door openers, occupancy-based automation (turning off a room's power when nobody's in it), and wildlife camera triggers. It's a common first choice for these projects because it needs no calibration beyond the two onboard trimmers, tolerates a wide input voltage range, and its digital output means any microcontroller can read it with one line of code.

Get everything in this build

The exact seven parts Soldr picked above, at today's live price and stock — each links straight to checkout, or add the whole tray in one click.

Part Price
Arduino Uno R3 CH340G ATmega328P Board ₹230 Add to cart →
HC-SR501 PIR Motion Sensor Module ₹70 Add to cart →
Active Buzzer Module 3-5V 85dB ₹45 Add to cart →
5mm LED Assorted Pack (Red, Green, Blue, Yellow, White) ₹120 Add to cart →
23 AWG Multi-Strand Breadboard Wire ₹10 Add to cart →
Male-to-Male Breadboard Jumper Wires (20cm, 24AWG) ₹40 Add to cart →
5V 2A Micro-USB Power Adapter ₹140 Add to cart →
Total ₹655 Add all 7 to cart →

Prices and stock verified live at the time this was written; Compoden's storefront always reflects the current price at checkout.

Built and Backed by Compoden

Every part above ships from Compoden's own India stock, tested for compatibility before it's carded together — not sourced individually and hoped to work. Delivery in 3–7 days across India, with COD and UPI available at checkout. If a part in this build doesn't perform as described, Compoden's support team will help you troubleshoot or replace it.

FAQ

How many pins does the HC-SR501 have and what are they?
Three: VCC (power), OUT (digital signal), and GND (ground). There's no I2C, SPI, or analog pin involved — it's a simple digital HIGH/LOW output.

Can the HC-SR501 be powered directly from an Arduino Uno?
Yes. It accepts a wide 4.5–20V DC input, so the Uno's 5V pin powers it comfortably, and its 3.3V logic HIGH on OUT reads correctly on the Uno's 5V-logic digital pins.

What's the difference between single trigger and repeatable trigger mode?
Single trigger sends one HIGH pulse per detection and ignores further motion until OUT drops LOW again. Repeatable trigger keeps OUT HIGH continuously for as long as motion keeps being detected, which is the more common default for alarms and lighting projects.

Why does the HC-SR501 need a warm-up period after power-on?
The pyroelectric sensor element needs roughly 30–60 seconds to stabilize to the room's ambient infrared level. Testing it immediately after power-up is the most common reason builders see false or stuck triggers.

Back to blog