Motion Activated Security Alarm

by DK968463 in Circuits > Arduino

33 Views, 0 Favorites, 0 Comments

Motion Activated Security Alarm

IMG_20260618_092942.jpg
IMG_20260618_092947.jpg

For my computer engineering project, I built a Motion Activated Security Alarm. The goal is to create a device that can be used at home to detect movement and then trigger a sound and a light alert right away. This project shows how basic home security systems work by combining sensors that detect motion with software that controls lights and sounds.

It uses a PIR motion sensor to sense when someone moves nearby. When motion is detected, an LED light flashes and a buzzer makes a sound. The main idea is to demonstrate how motion detection systems operate in homes and other places.

Supplies

51cM-uN86FL.jpg
abrauno_1__.jpg
active-buzzer.jpg
resistor_color_code.png
513XeStiRQL._SX425_.jpg
image.jpg
image_2026-06-21_191014220.png
Full_sized_breadboard_830_points_PiShopUS__36647.jpeg
2n3904-1024x1024.jpg

Planning

image_2026-06-21_193023896.png
Screenshot 2026-06-21 192217.png

I built my circuit on Tinkercad to test my ideas before moving on to the real circuit. If you're interested there is also a schematic view of the circuit. Furthermore you can visit this link to see how i connected them.

Assembling the Circuit.


1. Connecting the Power Rails

  1. Connect a red jumper wire from the 5V pin on the Arduino (Power section) to the positive rail of the breadboard.
  2. Connect a black jumper wire from the GND pin on the Arduino (Power section) to the negative rail of the breadboard.
  3. Connect a black jumper wire from the bottom negative rail to the top negative rail on the far left side. Then, connect a red jumper wire from the bottom positive rail to the top positive rail on the far left side.


2. Connecting the HC-SR501 PIR Sensor

  1. Plug the PIR Sensor pins into rows 9, 10, and 11 on the top section of the breadboard (columns i, j,h).
  2. Pin 1 (Middle - VCC): Connect a red jumper wire from j)10 to the top positive rail. Then, connect another yellow jumper wire from i)10 straight to Digital Pin 7 on the Arduino.
  3. Pin 2 (Left - OUT): Connect a yellow jumper wire from j)9 to h)9.
  4. Pin 3 (Right - GND): Connect a black jumper wire from j)11 to the top negative rail.


3. Connecting the Red LED & 330Ω Resistor

  1. Plug the Red LED across the row in the middle gap. Place the Anode (long leg) at f)20 and the Cathode (short leg) at f)19.
  2. Connect a blue jumper wire from the Cathode at f)19 directly to the e)19.
  3. Connect a black jumper wire from a)19 to the bottom negative rail.
  4. Plug the 330Ω Resistor into the board to the LED Anode with small a red wire.
  5. Connect a red jumper wire from f)25 straight to Digital Pin 8 on the Arduino.


4. Connecting the 2N3904 NPN Transistor

  1. Plug the NPN Transistor pins into rows 26, 27, and 28 at column e) spanning across row segments.
  2. In the diagram, it aligns at rows 26 (Emitter), 27 (Base), and 28 (Collector).
  3. Connect a red jumper wire from the Collector at a)28 down to the bottom positive rail.
  4. Connect a black jumper wire from the Base at a)27 down to the bottom negative rail.


5. Connecting the 10kΩ Resistor

  1. Plug the 10kΩ Resistor into the board from c)20 to c)24, connecting straight to the Emitter of the transistor.
  2. Connect a blue jumper wire from c)24 to c)26 to the Emitter of the transistor.
  3. Connect a green jumper wire from b)20 straight to Digital Pin ~11 on the Arduino.


6. Connecting the Piezo Buzzer

  1. Put the Piezo Buzzer on the far right edge of the breadboard.
  2. Connect the Positive (+) terminal row to the top positive rail using a red jumper wire at i)30.
  3. Connect the Negative (-) terminal row to the bottom negative rail using a black jumper wire at d)30.


7. Powering the Circuit

  1. Lastly once you're done assembling the circuit with all the components and wiring's are connected, You need to upload the code into the Arduino board. So below this there is a code you can copy and paste it into the Arduino app, IF you don't have windows or are using a school laptop/Chromebook that doesn't support Arduino or that doesn't let you install app due to the admin restrictions you can luckily use the Arduino Cloud website online to upload the code into the Arduino board. Click on "Get started for free" and then just login or create your account, next in your homepage click on the "Create new" button and select "Sketch" after that paste the following code below to your sketch and once done, plug in the USB cable of Arduino board to your device, select your board, brands and the port. Once your done that click on "Verify" then lastly click on "Upload". Hope for the best as your circuit should work as you connected it, If you encounter problems or your circuit isn't working, you should check the common issues like if your jumper wires are connected properly, as loose connections can prevent the circuit from functioning. If it still doesn't work visit this link and this link to help you out.

The Code

int ledPin = 8;
int pir_sensor = 7;
int pir_reader;
int buzzer = 9;

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

void loop()
{
pir_reader = digitalRead(pir_sensor);
Serial.println(pir_reader);

if (pir_reader == 1) {
triggerAlarm();
}
else {
digitalWrite(buzzer, LOW);
digitalWrite(ledPin, LOW);
delay(500);
}
}

void triggerAlarm()
{
digitalWrite(buzzer, HIGH);

for (int i = 0; i < 5; i++) {
digitalWrite(ledPin, HIGH);
delay(150);
digitalWrite(ledPin, LOW);
delay(150);
}
}

Conclusion

FI6HZXCMKRYPR63.jpg
FYM1FM8MKRYPR6A.jpg

This project taught me about troubleshooting, circuit design, and coding for Arduino.

And as for you, Have fun building this circuit!!!

Thank You!

FCNCZC1MKRYPR5S.jpg
F1I8R68MKRYPR5Y.jpg

Thank you for reading this Instructable! Feel free to ask questions or suggest improvements in the comments.