Project tutorial
Ultrasonic Tripwire

Ultrasonic Tripwire © GPL3+

Create a burglar-tripwire with the ultrasonic sensor.

  • 7,721 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
  • 6 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

Door Alarm With Ultrasonic Sensor

Project showcase by MattG

  • 4,883 views
  • 1 comment
  • 8 respects

Ultrasonic Sensor with Alarm, LCD and Temperature

Project tutorial by MichDragstar

  • 4,645 views
  • 7 comments
  • 19 respects

Ultrasonic Sensor with LCD Display Using 433MHz

Project tutorial by mcharrison500

  • 2,811 views
  • 0 comments
  • 15 respects

Auto Ultrasonic Car

by Ishaq Yang

  • 12,774 views
  • 2 comments
  • 15 respects

Ultrasonic Security System

Project tutorial by Ivan

  • 19,730 views
  • 19 comments
  • 56 respects

Arduino Laser Tripwire

Project tutorial by Ian Cumming

  • 15,384 views
  • 10 comments
  • 48 respects
Add projectSign up / Login