Project tutorial
Ultrasonic Tripwire

Ultrasonic Tripwire © GPL3+

Create a burglar-tripwire with the ultrasonic sensor.

  • 2,989 views
  • 7 comments
  • 14 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
  • 15 followers

Additional contributors

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

Published on

February 1, 2019

Members who respect this project

Avatar fofgrbxpczErospeterDefaultPhotoPhotoPhotoDefault

and 11 others

See similar projects
you might like

Similar projects you might like

Door Alarm With Ultrasonic Sensor

Project showcase by MattG

  • 6,542 views
  • 3 comments
  • 10 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

  • 13,235 views
  • 2 comments
  • 17 respects

Ultrasonic Security System

Project tutorial by Ivan

  • 20,680 views
  • 19 comments
  • 58 respects

Arduino Laser Tripwire

Project tutorial by Ian Cumming

  • 15,738 views
  • 12 comments
  • 48 respects
Add projectSign up / Login