What you can build with Arduino and basic sensors

An Arduino-based alarm system uses a microcontroller board to monitor sensors and trigger alerts when motion or doors are opened. The core pieces are an Arduino board (usually an Arduino Uno), motion sensors, door/window sensors, a buzzer or speaker, and some wiring. You write code that tells the Arduino to watch the sensors, and when one detects activity, the Arduino sounds the alarm or sends you a notification.

This is a real electronics project, not a software-only task. You will solder or breadboard connections, write C-like code in the Arduino IDE, and test each component before putting them together. The result is a working system you understand completely — because you built it — rather than a black-box device.

The advantage over a commercial system is cost and learning. A basic two-sensor setup costs $40 to $80 in parts. The disadvantage is that you are responsible for the code, the wiring, and the reliability. A commercial alarm company monitors your system 24/7 and responds to false alarms. Your Arduino system does what you programmed it to do, nothing more.

Key Takeaways

  • An Arduino Uno, motion sensor, door sensor, buzzer, and breadboard are the minimum parts needed, costing $40 to $80 total.
  • You write the code in the free Arduino IDE and upload it to the board via USB, then the system runs on its own or on battery power.
  • Motion sensors detect movement in a room; door sensors detect when a door or window opens; buzzers make noise or you can add a speaker for voice alerts.
  • Testing each sensor individually before combining them prevents hours of debugging when the full system does not work as expected.
  • This is a learning project suitable for people with some electronics experience or willingness to learn; it is not a replacement for professional home security.

The parts you need and what they do

Start with an Arduino Uno board. It is the most common Arduino model, costs about $25, and has enough input pins for a small alarm system. You plug it into your computer via USB to write and upload code, then it can run on battery power or a wall adapter.

A PIR motion sensor (passive infrared) detects heat from moving bodies. When motion is detected, it sends a signal to one of the Arduino's input pins. These cost $5 to $10 and come as small modules you can breadboard directly. They have a warm-up time of 30 to 60 seconds after power-on, and they can be adjusted for sensitivity and delay time using small dials on the module.

A door/window sensor is a magnetic reed switch: a magnet on the door, a switch on the frame. When the door opens, the magnet moves away and the switch opens, sending a signal to the Arduino. These cost $2 to $5 per sensor. You can add multiple door sensors to the same system by wiring them to different input pins.

A buzzer or speaker produces the alarm sound. A simple piezo buzzer costs $1 to $3 and makes a loud beep. A small speaker with an amplifier module costs $5 to $15 and lets you play recorded sounds or voice alerts. Both connect to an output pin on the Arduino.

You will also need a breadboard (about $5), jumper wires (about $5 for a pack), and a USB cable to connect the Arduino to your computer. If you want the system to run without being plugged in, add a 9V battery connector (about $2) or a power bank (about $15 to $30).

Wiring the sensors to the Arduino

Each sensor connects to the Arduino in the same basic way: power, ground, and signal. Power and ground come from the Arduino's 5V and GND pins. The signal wire goes to one of the digital input pins (labeled D0 through D13).

A PIR motion sensor has three pins: VCC (power), GND (ground), and OUT (signal). Plug the VCC pin into the Arduino's 5V pin using a jumper wire. Plug the GND pin into the Arduino's GND pin. Plug the OUT pin into a digital input pin, such as D2. The sensor is now ready to send motion signals to pin D2.

A door sensor (reed switch) also has two wires: one to 5V, one to a digital input pin such as D3. When the door is closed, the switch is closed and the pin reads HIGH. When the door opens, the switch opens and the pin reads LOW. Your code watches for this change.

A buzzer has two pins: positive (longer leg) and negative (shorter leg). The positive pin goes to a digital output pin such as D8. The negative pin goes to GND. When you send a HIGH signal to D8, the buzzer sounds. When you send LOW, it stops.

Use a breadboard to organize the wires so they do not tangle. Plug the Arduino into the breadboard's power rails, then run jumper wires from the sensors to the same rails. This keeps everything in one place and makes it easy to swap out a sensor if it fails.

Writing the code in the Arduino IDE

Download the free Arduino IDE from arduino.cc. Install it, then open it and create a new sketch. A sketch is a program for the Arduino, written in a language that looks like C.

At the top of your sketch, define which pins you are using:

int motionPin = 2; int doorPin = 3; int buzzerPin = 8;

In the setup() function, tell the Arduino which pins are inputs and which are outputs:

void setup() {   pinMode(motionPin, INPUT);   pinMode(doorPin, INPUT);   pinMode(buzzerPin, OUTPUT); }

In the loop() function, read the sensors and trigger the buzzer if either detects activity:

void loop() {   int motion = digitalRead(motionPin);   int door = digitalRead(doorPin);      if (motion == HIGH || door == LOW) {     digitalWrite(buzzerPin, HIGH);     delay(5000);     digitalWrite(buzzerPin, LOW);   } }

This code reads both sensors every loop cycle. If motion is detected (HIGH) or the door is open (LOW), it turns the buzzer on for 5 seconds, then off. The loop runs hundreds of times per second, so the system responds almost instantly.

Connect your Arduino to your computer via USB. In the Arduino IDE, select the correct board (Arduino Uno) and COM port from the Tools menu. Click the Upload button. The code uploads to the Arduino and starts running immediately.

Testing each sensor before combining them

Do not wire everything together and hope it works. Test each sensor alone first.

For the motion sensor: upload a simple sketch that reads the motion pin and prints the result to the Serial Monitor (a text window in the Arduino IDE). Wave your hand in front of the sensor. You should see the pin change from LOW to HIGH. If it does not, check that the sensor is powered, that the wires are seated firmly in the breadboard, and that you are using the correct pin number in your code.

For the door sensor: open and close the door while watching the Serial Monitor. The pin should change from HIGH (closed) to LOW (open). If the sensor does not respond, check that the magnet is aligned with the switch and that the wires are not loose.

For the buzzer: upload a sketch that turns the buzzer on and off every second. You should hear a beeping sound. If the buzzer is silent, check that the positive and negative wires are in the correct pins and that the pin is set to OUTPUT in your code.

Once each sensor works alone, combine them into the full alarm sketch and test again. This approach saves time because you know which component is broken if something does not work.

Adding features: delays, disarm buttons, and notifications

A basic alarm sounds immediately when triggered. You can improve it by adding a delay before the alarm sounds, so you have time to disarm it after opening a door.

Add a button to your breadboard (about $1) and wire it to an input pin such as D4. In your code, check if the button is pressed before sounding the alarm. If it is, skip the alarm and reset the system. This gives you a way to turn off the alarm without unplugging the Arduino.

For notifications, you can add a WiFi module such as an Arduino MKR WiFi 1010 (about $35) instead of a basic Uno. This lets you send an email or text message when the alarm triggers, so you know about it even if you are not home. The code is more complex, but Arduino has tutorials for WiFi on their website.

You can also add an LED that blinks when the system is armed, or a buzzer that beeps once per second instead of continuously. These are all small changes to the loop() function.

Powering the system without a computer

While your Arduino is plugged into your computer, it runs on USB power. To use it as a standalone alarm, you need a separate power source.

A 9V battery connector plugs into the Arduino's power jack and provides enough power for the board, sensors, and buzzer for several hours. A USB power bank (the kind you charge your phone with) plugged into a USB-to-barrel-jack adapter also works and lasts longer. A wall adapter (5V, 1A) is the cheapest option if the alarm will stay in one place.

Test the system on battery power before relying on it. Some sensors draw more current than others, and a weak battery may cause the Arduino to reset or behave unpredictably. If the system resets, try a stronger power source.

If you want the alarm to run for days or weeks without recharging, consider a solar panel (about $20) connected to a rechargeable battery pack. This is more complex to wire, but it keeps the system running indefinitely.

Frequently Asked Questions

Can I use this system to monitor multiple rooms?

Yes. An Arduino Uno has 14 digital input pins, so you can connect up to 14 sensors. Add more motion sensors to different rooms and wire each to a different pin. Your code reads all of them in the loop() function and triggers the alarm if any sensor detects activity.

What happens if a sensor fails or gets disconnected?

The Arduino will read the pin as LOW (or HIGH, depending on how you wired it) and may trigger a false alarm or fail to detect real activity. Add a check in your code that logs sensor status to the Serial Monitor so you can see which sensor is failing. You can also add a heartbeat LED that blinks once per second to show the system is running.

Can I make the alarm send me a text message?

Not with a basic Arduino Uno. You need a WiFi or cellular module such as an Arduino MKR WiFi 1010 or a separate GSM shield (about $30 to $50). These modules connect to the internet and can send SMS or email. Arduino's website has tutorials for both.

How loud is the buzzer?

A piezo buzzer is about 85 to 95 decibels, roughly as loud as a smoke detector. A speaker with an amplifier can be louder or quieter depending on the volume setting. Test it in the room where you plan to use it to make sure it is loud enough to hear.

Is this system as reliable as a commercial alarm?

No. Commercial systems are tested, monitored 24/7, and backed by insurance. Your Arduino system is only as reliable as your code and wiring. If the power fails, the Arduino stops. If a wire comes loose, the sensor stops working. If you have a bug in your code, the alarm may not trigger. This is a learning project, not a replacement for professional security.