Read a PIR Motion Sensor
Detect movement and tune sensitivity and delay.
Read a PIR Motion Sensor is a free Arduino & IoT Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Arduino & IoT Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
What a PIR Detects
A PIR sensor watches for changes in infrared heat. When a warm body like a person moves across its view, it fires.
Why It Sees Movement
PIR stands for passive infrared. It only reacts to a change in heat, so a still object soon fades from notice while motion stands out.
It Has Three Pins
A typical PIR module has three pins: VCC for power, GND for ground, and OUT for the digital signal you read.
Power It Up
Most PIR modules run on 5V. Connect VCC to 5V and GND to ground, just like any other digital sensor.
OUT Is Digital
The OUT pin gives a clean digital signal. It goes HIGH when motion is detected and LOW when the area is calm.
Set the Pin as Input
Tell the board that the OUT pin is an input so it can listen. Do this once inside setup().
pinMode(2, INPUT);Read the Motion State
Read the sensor with digitalRead. A returned HIGH means it just sensed movement nearby.
int motion = digitalRead(2);Act on Detection
Wrap the reading in an if check so your code does something, like light an LED, only when motion is HIGH.
if (motion == HIGH) {
// movement detected
}Tune the Delay Trim
The on-board delay trimpot sets how long OUT stays HIGH after motion. Turn it to hold the signal longer or shorter.
Tune the Sensitivity Trim
The second trimpot adjusts sensitivity, the range at which motion triggers. Lower it to ignore far-off movement.
Let It Warm Up
Give a PIR up to a minute to calibrate after power-on. Early readings can be jittery until it settles.
Quick Check
What does a PIR sensor actually respond to?
Recap: Sensing Motion
You wired a PIR with VCC, GND, and OUT, read it with digitalRead, and tuned the delay and sensitivity trimpots.
Frequently asked questions
Is the “Read a PIR Motion Sensor” lesson free?
Yes — the full text of “Read a PIR Motion Sensor” is free to read here on the web, and the Arduino & IoT Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Arduino & IoT Academy course, upgrade to CoddyKit PRO.
What will I learn in “Read a PIR Motion Sensor”?
Detect movement and tune sensitivity and delay. You practise Arduino & IoT Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Arduino & IoT Academy?
No prior experience is required. Arduino & IoT Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Read a PIR Motion Sensor” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Arduino & IoT Academy lesson?
Yes. Every Arduino & IoT Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Read a PIR Motion Sensor
- Measure Light with an LDR
- Set a Light Threshold
- Automatic Night Light