Here is an Arduino Uno based motion-activated intruder alert system which beeps and lights the LED when someone is within its range.
You can adjust the delay time between motions using the Time delay pot on the side of the PIR module. The Sensitivity pot adjusts the motion-sensing range of the module.
Also Read:
Click to enlarge the image.

If you want the buzzer to keep beeping and the LED to remain on so long as there is a person within the range of the motion sensor, you can put the Retrigger setting jumper at H.
The output will remain HIGH so long as there is motion.
You will require:
- 1 X Arduino Uno
- 1 X 220 ohm resistor
- 1 X PIR motion sensor module
- 1 X Buzzer
- 1 X LED
- A breadboard
- Some connecting wires
Connect the circuit as shown in the breadboard diagram below.
Click to view enlarged image.
Connect the components to Arduino as indicated below;
| Component | Arduino Pin |
|---|---|
| PIR module | 6 |
| Buzzer | 4 |
| LED | 2 |
The RED wire from the PIR diagram above is the motion sensor output. Connect it to pin 6 of Arduino.
The black wire is ground and the red wire from the PIR module is positive 5V.
You can also check the underside of the PIR module for proper connections.
After you have double-checked the circuit connection, upload this code to Arduino;
int buzzerpin = 4;
int pirSensorOut = 6;
int securityled = 2;
int sensorValue = 0; //Variable to hold motion status, 0 means no output
int pirState = LOW; // we start assuming no motion detected
void setup() {
//setup pins as output or input
pinMode(securityled, OUTPUT);
pinMode(buzzerpin, OUTPUT);
pinMode(pirSensorOut, INPUT);
}
void loop() {
sensorValue = digitalRead(pirSensorOut);
if (sensorValue == 1) {
digitalWrite(securityled, HIGH); //Turn on security LED
//tone(pin, frequency, duration)
tone(buzzerpin, 2000, 500);
delay(800);
tone(buzzerpin, 2000, 500);
int pirState = HIGH;
}
else {
digitalWrite(securityled, LOW); // turn off security light
pirState = LOW;
noTone(buzzerpin); //Turn off buzzer
}
}
After uploading, wait for at least 60 seconds to allow the PIR module to calibrate itself with the surrounding environment.
During this time, the motion sensor will keep on retriggering itself on and off, so be patient.
This is what the code does;
We read the output of the PIR motion sensor and assign it to the variable sensorValue
sensorValue = digitalRead(pirSensorOut);
Then we check if there is motion. A 1 indicates motion is detected
if (sensorValue == 1) { digitalWrite(securityled, HIGH); //Turn on security LED //tone(pin, frequency, duration) tone(buzzerpin, 2000, 500); delay(800); tone(buzzerpin, 2000, 500); int pirState = HIGH; }
The buzzer will produce a tone of the set frequency and duration. At the same time, the LED will light.
When motion ceases, the sound is cut-off with the code
noTone(buzzerpin);
The LED will also go off.
If you have found this Arduino motion sensor project helpful, please like and share.
If you need any assistance with this project, you can reach me through the comment section or the contact form.


