lidom
Published © GPL3+

Ultrasonic security system

Beeps the closer someone or something gets to your stuff

BeginnerFull instructions provided812
Ultrasonic security system

Things used in this project

Story

Read more

Schematics

Ultra sonic diagram

the layout for the hardware

Ultra sonic layout

the image of the layout of the componets

Code

Ultra sonic security system code

C/C++
the software that you put on the Arduino to run your project
//Security Alarm with Ultrasonic Sensor//

#define trigPin 6  
#define echoPin 5
#define buzzer 2
float new_delay; 


void setup() 
{
  Serial.begin (9600); 
  pinMode(trigPin, OUTPUT); 
  pinMode(echoPin, INPUT);
  pinMode(buzzer,OUTPUT);
  
}


void loop() 
{
  long duration, distance;
  digitalWrite(trigPin, LOW);        
  delayMicroseconds(2);              
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);           
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration/2) / 29.1;
  new_delay= (distance *3) +30;
  Serial.print(distance);
  Serial.println("  cm");
  if (distance < 50)
  {
   digitalWrite(buzzer,HIGH);
   delay(new_delay);
   digitalWrite(buzzer,LOW);
 
  }
  else
  {
    digitalWrite(buzzer,LOW);

  }
  
 delay(200);
}

Credits

lidom
0 projects • 0 followers
Contact

Comments

Please log in or sign up to comment.