Security Alarm or Parking Sensor

Introduction: Security Alarm or Parking Sensor

In this Instructables page, I will tell you how to make a security alarm or parking sensor with Arduino. This device can be used as a security alarm or a parking senor because it is a device that will detect how close you are to an object, the led will shine faster if the object gets closer, and there will be an LCD board that will say how close you are with the object. The materials you will need is in the supplies section.

Supplies

  1. an Arduino Uno or a Leonardo board.
  2. infrared sensor
  3. LCD board
  4. little speaker
  5. some wire

Step 1: Step 1: Connect the Wires to the Right Place

  1. LCD board : Scl to Scl Sda to Sda Vcc to positive on the board Gnd to negative on the board
  2. Sensor: Vcc to positive Gnd to negative Trig to digital pin 9 Echo to digital pin 10
  3. speaker: positive to digital pin 11 negative to gnd
  4. Led: positive to digital pin 13 negative to negative on the board

Step 2: Step 2: Code

code and picture of i#include

const int trigPin = 9;

const int echoPin = 10;

const int buzzer = 11;

const int ledPin = 13;

long duration;

int distance;

LiquidCrystal_I2C lcd_I2C_27(0x27,16,2);

void setup() { lcd_I2C_27.init (); // initialize the lcd lcd_I2C_27.backlight();

pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT);

pinMode(buzzer, OUTPUT); pinMode(ledPin, OUTPUT);

Serial.begin(9600);

}

void loop() {

lcd_I2C_27.clear(); lcd_I2C_27.setCursor(0 , 0) ;

distance=3000;

digitalWrite(trigPin, LOW);

delayMicroseconds(2);

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);

distance= duration/40;

if (distance <= 10) { digitalWrite(buzzer, HIGH); digitalWrite(ledPin, HIGH); delay(250); digitalWrite(buzzer, LOW); digitalWrite(ledPin, LOW); } else if(distance <= 25) { digitalWrite(buzzer, HIGH); digitalWrite(ledPin, HIGH); delay(500); digitalWrite(buzzer, LOW); digitalWrite(ledPin, LOW); } else if(distance<= 50) { digitalWrite(buzzer, HIGH); digitalWrite(ledPin, HIGH); delay(1000); digitalWrite(buzzer, LOW); digitalWrite(ledPin, LOW); }

else { digitalWrite(buzzer, LOW); digitalWrite(ledPin, LOW); } lcd_I2C_27.print(distance); delay(500); }

Step 3: Step 3: Test

instruction(connect your board to your computer.....)

Step 4: Step 4: Make the Outer Layer

..

Be the First to Share

    Recommendations

    • Lamps and Lighting Contest

      Lamps and Lighting Contest
    • Fashion Challenge

      Fashion Challenge
    • First Time Author Contest

      First Time Author Contest

    Comments