Arduino • FREE PROJECT

Motion Detection Project

Motion Detection Project circuit diagram
Beginner Arduino ⏱ 45 Minutes

Use a PIR sensor to detect human movement and automatically switch ON an LED. This demonstrates the technology used in security systems, automatic lights, smart homes, and occupancy detection.

What You Will Learn

  • How ultrasonic (sonar) distance sensing works
  • Reading sensor pulses with pulseIn()
  • Converting pulse time into centimetres
  • Using the Serial Monitor to debug sensor data

Components Required

Arduino UNO R3 HC-SR501 PIR Sensor 5mm LED 220Ω Resistor Breadboard Jumper Wires
BUILD IT STEP BY STEP

Follow along and build with confidence.

Every step includes a visual reference and a plain-language explanation, so you always know what to do next.

STEP 01

Upload the Code

💻

This sketch triggers a pulse, times the echo, converts it to centimetres using the speed of sound, and prints the result every 500ms.

cpp
const int pirPin = 2;
const int ledPin = 8;

void setup() {
  pinMode(pirPin, INPUT);
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  int motion = digitalRead(pirPin);

  if (motion == HIGH) {
    digitalWrite(ledPin, HIGH);
    Serial.println("Motion Detected!");
  } else {
    digitalWrite(ledPin, LOW);
    Serial.println("No Motion");
  }

  delay(100);
}
STUCK ON SOMETHING?

Troubleshooting & common fixes.

Serial Monitor shows 0 or blank values.

Confirm the baud rate in the Serial Monitor is set to 9600, matching Serial.begin(9600) in the code.

Readings look inconsistent or jump around.

Make sure nothing is placed right in front of the sensor (under ~2cm) and that the sensor is on a stable, flat mount.

No readings at all.

Re-check TRIG is on pin 9 and ECHO is on pin 10, and that VCC/GND are wired correctly — a reversed connection can prevent it from powering on.

WANT GUIDED, HANDS-ON HELP?

Bring this project to life with a mentor.

Loved building this for free? Our instructor-led workshops go deeper with kits, live guidance and more advanced builds.

Plan a Workshop →
KEEP BUILDING

More free workshops.

💡

LED Blinking Using Arduino UNO

Learn how to control an LED using Arduino UNO by making it turn ON and OFF automatically. This is the basic concept behind indicator lights, warning lights, and signal systems used in real-world electronic devices.

View Free Project →
🛤️

Automatic Street Light

Build a smart street light that automatically turns ON when it gets dark and OFF during daylight using an LDR sensor. This concept is commonly used in street lights, garden lights, parking areas, and energy-saving lighting systems.

View Free Project →
📲

Voice Control LED Using Bluetooth

Control an LED wirelessly using voice commands sent from a smartphone through Bluetooth. This introduces students to wireless control and smart-home applications, such as controlling lights, fans, and other devices remotely.

View Free Project →