Project tutorial
Ultrasonic Tripwire

Ultrasonic Tripwire © GPL3+

Create a burglar-tripwire with the ultrasonic sensor.

  • 8,542 views
  • 13 comments
  • 24 respects

Components and supplies

Necessary tools and machines

Computer

Apps and online services

About this project

Basically, just assemble it with the Fritzing® diagram below, and uplode de code.

Code

Tripwire with Nano and UltrasonicC/C++
#define trigPin 9
#define echoPin 10
long duration;
int distance;
long firstoff;
int distancefirst;

void setup()
{
Serial.begin(9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
delay(1000);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
firstoff = pulseIn(echoPin, HIGH);
distancefirst = firstoff*0.034/2; // cm
}

void loop()
{

digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance= duration*0.034/2; // cm
//distance = duration * 0.0133 / 2; // in
Serial.println(distance);
delay(1000);
Serial.println(distancefirst);



if (distance <= distancefirst - 5)
{
tone(3, 500, 500);
delay(500);
tone(3, 800, 500);
delay(500);
delay(50);
}
}

Schematics

How to make the circuit
Trippwire waeirjt the utltarsonic bb mnvbpeylqp

Comments

Author

Will the star
Will_the_Star
  • 8 projects
  • 20 followers

Additional contributors

  • Manufacturing/making parts by Arduino/Genuino/Iduino/Duinotech

Published on

February 1, 2019

Members who respect this project

Avatar fofgrbxpczErospeterDefaultPhotoPhotoPhotoDefaultDefault

and 16 others

See similar projects
you might like

Similar projects you might like

Ultrasonic Glasses for the Blind

Project tutorial by Team GardnerTech

  • 17,213 views
  • 27 comments
  • 78 respects

Door Alarm With Ultrasonic Sensor

Project showcase by MattG

  • 15,588 views
  • 5 comments
  • 18 respects

Ultrasonic Sensor with Alarm, LCD and Temperature

Project tutorial by MichDragstar

  • 11,136 views
  • 7 comments
  • 25 respects

Ultrasonic Sensor with LCD Display Using 433MHz

Project tutorial by mcharrison500

  • 10,408 views
  • 1 comment
  • 24 respects

Ultrasonic Security System

Project tutorial by Ivan

  • 38,843 views
  • 27 comments
  • 87 respects

Auto Ultrasonic Car

by Ishaq Yang

  • 25,189 views
  • 2 comments
  • 19 respects
Add projectSign up / Login