Project 4
PIR Motion Sensor - Arduino Uno
Project Description
A motion detector is an electronic device that senses movement within a specific area and triggers a response such as turning on a light, sounding an alarm, or sending a notification. It works by detecting changes in infrared radiation (PIR), microwave signals. Motion detectors are widely used in security systems, automatic lighting, smart home devices, and energy-saving applications because they operate automatically and require very little power.
The sensitivity of the PIR sensor can be adjusted with a small screwdriver using the potetiometers beneath sensor.
Components
- Arduino Uno
- PIR Sensor
- Jumper wires
- Breadboard
- LEDÂ
- Resistor (220 Ohm) - [Red-Red-Brown-Gold]
Code
int pirPin = 8; // PIR sensor output pin
int ledPin = 7; // LED pin
void setup() {
pinMode(pirPin, INPUT); // PIR sensor as input
pinMode(ledPin, OUTPUT); // LED as output
Serial.begin(9600);
Serial.println("PIR Sensor Active...");
}
void loop() {
int motion = digitalRead(pirPin); // Read PIR output
if (motion == HIGH) {
digitalWrite(ledPin, HIGH); // Turn LED ON
Serial.println("Motion Detected");
} else {
digitalWrite(ledPin, LOW); // Turn LED OFF
Serial.println("No Motion");
}
delay(100); // Small delay to avoid rapid toggling
}
Taking things further
- A relay can be added to control lights and make an energy saving light and automatic for corridors, bathrooms and outdoor areas
- Add a buzzer to make a motion sensitive security system.
- A camera module can be triggered to begin recording
Power supply

