vamsivenkata
Created July 14, 2020 © GPL3+

Intruder Detector

Make an awesome project in which you can detect Intruders passing through unauthorized areas.

IntermediateShowcase (no instructions)12
Intruder Detector

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Standard LCD - 16x2 White on Blue
Adafruit Standard LCD - 16x2 White on Blue
×1
Elegoo Buzzer (3 pins)
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Rotary potentiometer (generic)
Rotary potentiometer (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Schematics

Replicate it

Code

Code

C/C++
Paste in IDE
/******************************************
  Website: www.elegoo.com

  Time:2017.12.12

 ******************************************/
#include <NewPing.h>
#include <LiquidCrystal.h>

#define TRIGGER_PIN  5  // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN     6  // Arduino pin tied to echo pin on the ultrasonic sensor.
#define MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.
int buzzer = 3;//the pin of the active buzzer
LiquidCrystal lcd(7,8,9,10,11,13);

NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.

void setup() {
  pinMode(buzzer, OUTPUT); //initialize the buzzer pin as an output
  Serial.begin(9600); // Open serial monitor at 9600 baud to see ping results.
  lcd.begin(16, 2);
  lcd.print("Hello World: ");
}

void loop() {
  delay(500);  // Wait 10ms between pings. 10ms should be the shortest delay between pings.
  unsigned int uS = sonar.ping(); // Send ping, get ping time in microseconds (uS).
  Serial.print("Ping: ");
  Serial.print(uS / US_ROUNDTRIP_CM); // Convert ping time to distance and print result (200 = outside set distance range, no ping echo)
  Serial.println("cm");
  
  
  int safetyDistance = uS / US_ROUNDTRIP_CM;

  if (safetyDistance > 1 && safetyDistance <= 186) {
    lcd.setCursor(0, 0);
    lcd.print("Warning: ");
    lcd.setCursor(0, 1);
    lcd.print("Security Breach");
    
   digitalWrite(buzzer, HIGH);
  } else {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("All Right");
    lcd.setCursor(0, 1);
    lcd.print("");
    digitalWrite(buzzer, LOW);
  }
}

Credits

vamsivenkata
4 projects • 0 followers
Contact

Comments

Please log in or sign up to comment.