Sitemap

Burglar Alarm System — Arduino

2 min readDec 1, 2023

--

Arduino Based Burglar Alarm System Demonstration

I successfully crafted a burglar alarm system using an Arduino Uno, incorporating an ultrasonic sensor SR04 and a buzzer. The Arduino controlled the system, the ultrasonic sensor detected movement, and the buzzer sounded a robust alarm in response. This DIY creation represents a powerful fusion of technology and innovation for enhanced home security.

Necessary Components

  1. Arduino Board
515b4656ce395f8a38000000.png (551×405) (sparkfun.com)

2. Ultrasonic Sensor (SR04)

hc043.jpg (700×700) (digitalelectronics.lk)

3. Buzzer

3.5–5.5v-standard-active-buzzer-module-for-arduino-550x550.JPG (550×550) (flyrobo.in)

Get damian-chamel’s stories in your inbox

Join Medium for free to get updates from this writer.

4. LED light

light-emitting-diode-or-led-diode-with-individual-parts-and-structure-anvil-and-post.jpg (573×612) (istockphoto.com)

5. 100 Ω Resistor

Press enter or click to view image in full size
121–5007–00_1.jpg (2571×2000) (plentymarkets.com)

Schematic Diagram

Press enter or click to view image in full size
Schematic diagram of the above system

Arduino Program (source code)

// Arduino pin configuration
#define TRIG_PIN 13
#define ECHO_PIN 12
#define IND_LED 11
#define BUZ_PIN 9

bool entered;
long duration, distance;

void setup() {
Serial.begin(9600);
pinMode(TRIG_PIN, OUTPUT);
pinMode(ECHO_PIN, INPUT);
pinMode(IND_LED, OUTPUT);
pinMode(BUZ_PIN, OUTPUT);

entered = false;
}

void loop() {
// Clear sensor
digitalWrite(TRIG_PIN, LOW);
delayMicroseconds(2);

// Generate 10 microseconds pulse to the sensor
digitalWrite(TRIG_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG_PIN, LOW);

duration = pulseIn(ECHO_PIN, HIGH); // in microseconds
distance = (duration / 2) / 29.1; // in cm

// Assuming door width is 10cm (If someone crossed the 10cm range, alarm will be raised)
if (distance < 10) {
entered = true;
}

// Alarm raises when someone crossed the range
if (entered) {
// Turn on alarm light
digitalWrite(IND_LED, HIGH);

// Generate 2KHz buzzer noise
tone(BUZ_PIN, 2000);
delay(500);

digitalWrite(IND_LED, LOW);
noTone(BUZ_PIN);
}

Serial.print(distance);
Serial.println(" cm");
delay(500);
}

Link to the simulation

--

--

damian-chamel
damian-chamel

Written by damian-chamel

A person loves programming, especially high-performance computing, and graphics. Always trying to dig deep into the subject.