Arduino security alarm system

This project will detect any intruders and alarm you using the components of an LED, a buzzer, ultrasonic sensor, and a LCD display.

Components and supplies

Resistor 220 ohm

9V battery (generic)

Rotary potentiometer (generic)

Jumper wires (generic)

RGB LCD Shield Kit, 16x2 Character Display

Ultrasonic Sensor - HC-SR04 (Generic)

Bench Power Supply, DC Power Module

Apps and platforms

We are using this code to detect intruders and alarm you

1#include LiquidCrystal.h> 2LiquidCrystal LCD(A0,A1,A2,A3,A4,A5); // the pins for the lcd display 3#define trigPin 13 4#define echoPin 12 5//for the ultrasonic sensor 6const int buzzer = 11; 7const int ledPin = 10; 8//the integers for the led and buzzer 9 10void setup() 11 12 pinMode(trigPin, OUTPUT); 13 pinMode(echoPin, INPUT); 14 pinMode(buzzer, OUTPUT); 15 pinMode(ledPin, OUTPUT); 16 LCD.begin(16,2); // contacting the lcd display 17 > 18 19void loop() 20 21 22 long duration, distance; 23 digitalWrite(trigPin, LOW); 24 delayMicroseconds(2); 25 digitalWrite(trigPin, HIGH); 26 delayMicroseconds(10); 27 digitalWrite(trigPin, LOW); 28 duration = pulseIn(echoPin, HIGH); 29 distance = (duration/2) / 29.1; 30 delay(500); 31 32 LCD.setCursor(0,1); 33 LCD.print(" "); 34 LCD.setCursor(0,1); 35 LCD.print(distance); 36 LCD.print(" cm"); 37 //to print the distance the ultrasonic sensor is detecting when it finds an object 38 39 if (distance  40)  40 LCD.setCursor(0,0); 41 LCD.print("Intruder "); 42 digitalWrite(buzzer, HIGH); 43 digitalWrite(ledPin, HIGH); 44 //saying if the device detects an object in a distance lower than 40 cm it will alarm you that there is an inrtuder. The lcd display will say intruder. 45 > 46 else 47  48 LCD.setCursor(0,0); 49 LCD.print(" "); 50 digitalWrite(buzzer, LOW); 51 digitalWrite(ledPin, LOW); 52 // and if there is no object in a distance lower than 40 cm it will say to keep the buzzer and led blank. There will also be no words printed on the lcd display 53 >

We are using this code to detect intruders and alarm you

1#include LiquidCrystal.h> 2LiquidCrystal LCD(A0,A1,A2,A3,A4,A5); // the pins for the lcd display 3#define trigPin 13 4#define echoPin 12 5//for the ultrasonic sensor 6const int buzzer = 11; 7const int ledPin = 10; 8//the integers for the led and buzzer 9 10void setup() 11 12 pinMode(trigPin, OUTPUT); 13 pinMode(echoPin, INPUT); 14 pinMode(buzzer, OUTPUT); 15 pinMode(ledPin, OUTPUT); 16 LCD.begin(16,2); // contacting the lcd display 17 > 18 19void loop() 20 21 22 long duration, distance; 23 digitalWrite(trigPin, LOW); 24 delayMicroseconds(2); 25 digitalWrite(trigPin, HIGH); 26 delayMicroseconds(10); 27 digitalWrite(trigPin, LOW); 28 duration = pulseIn(echoPin, HIGH); 29 distance = (duration/2) / 29.1; 30 delay(500); 31 32 LCD.setCursor(0,1); 33 LCD.print(" "); 34 LCD.setCursor(0,1); 35 LCD.print(distance); 36 LCD.print(" cm"); 37 //to print the distance the ultrasonic sensor is detecting when it finds an object 38 39 if (distance  40)  40 LCD.setCursor(0,0); 41 LCD.print("Intruder "); 42 digitalWrite(buzzer, HIGH); 43 digitalWrite(ledPin, HIGH); 44 //saying if the device detects an object in a distance lower than 40 cm it will alarm you that there is an inrtuder. The lcd display will say intruder. 45 > 46 else 47  48 LCD.setCursor(0,0); 49 LCD.print(" "); 50 digitalWrite(buzzer, LOW); 51 digitalWrite(ledPin, LOW); 52 // and if there is no object in a distance lower than 40 cm it will say to keep the buzzer and led blank. There will also be no words printed on the lcd display 53 >