Invisible Tripwire

by K04252013 in Circuits > Arduino

35 Views, 0 Favorites, 0 Comments

Invisible Tripwire

Image 2-12-26 at 9.38 PM.jpg
Screenshot 2026-02-12 at 9.41.05 PM.png
Screenshot 2026-02-12 at 9.41.25 PM.png

I made an invisible tripwire. Here's why: Invisible tripwires would be useful because they could provide security and safety without being noticed. Since they cannot be easily seen, they would be effective at detecting intruders without giving them a chance to avoid the system. Invisible tripwires could be used to protect homes, museums, or restricted areas by triggering alarms when someone crosses a boundary. They could also help in safety situations, such as warning workers if someone enters a dangerous area. Overall, invisible tripwires would improve protection and awareness while remaining discreet and efficient. Thinking about this, with my need for creation, I had to try and make one. It worked! Here are the simple instructions:

Supplies

Screenshot 2026-02-12 at 9.42.14 PM.png
Screenshot 2026-02-12 at 9.42.38 PM.png
Screenshot 2026-02-12 at 9.43.04 PM.png
Screenshot 2026-02-12 at 9.43.28 PM.png
Screenshot 2026-02-12 at 9.43.51 PM.png

You need:

  1. Arduino Uno
  2. Breadboard (Optional only if you can solder)
  3. Ultrasonic distance sensor HC-SR04
  4. Jumper wires
  5. Something to upload and write the code on (needs arduino editor: https://login.arduino.cc/login?state=hKFo2SBvdE5tR1hXRkx4TnJJeXRFY1JTNjhuR21kb0JjVjh1N6FupWxvZ2luo3RpZNkgRkdGZTJyczVlZC1jNnppbW1ZWVpnaXFOdzVzM0Z5b0yjY2lk2SBlOXFpcEEyTjBrOVA4dnZyZTlmZEdjNnU5S2w5ZUhTUA&client=e9qipA2N0k9P8vvre9fdGc6u9Kl9eHSP&protocol=oauth2&scope=openid+profile+email&redirect_uri=https%3A%2F%2Fapp.arduino.cc&response_type=code&response_mode=query&nonce=ZHFhflo2UlFCa2htTFlhS21IM1h1REVORlM1LmkuU35NQ1BjdHV%2BTXdSTg%3D%3D&code_challenge=YmWNjgTsAmHE0Rwu0MzsNTQdP2I-F0aljz2Qev_pnXo&code_challenge_method=S256&auth0Client=eyJuYW1lIjoiYXV0aDAtc3BhLWpzIiwidmVyc2lvbiI6IjIuMS4zIn0%3D#/sso/login
  6. It only takes like 3 min to set up an account

The Connections

Screenshot 2026-02-12 at 9.02.17 PM.png

To start you need to connect the pins. If you don't want to use a breadboard, another option is soldering. The breadboard still is highly recommended. Here are the connections:

  1. Gnd - Gnd of sensor
  2. 5v - 5v of sensor
  3. D2 - Buzzer positive
  4. D3- Trig of sensor
  5. D4- Echo of sensor
  6. Gnd- Buzzer negative

If you want to connect any modifications, now is the time.

The Code

Screenshot 2026-02-12 at 9.08.05 PM.png

For the code I decided to use simple if conditions instead of overcomplicating it. Here is the code. I added explanations for it in the code but if you have any questions feel free to ask in the comments. I made a comment where you can adjust the tripwire length in the code.


#define TRIG_PIN 3

#define ECHO_PIN 4

#define BUZZER_PIN 2


long duration;

float distance;


void setup() {

pinMode(TRIG_PIN, OUTPUT);

pinMode(ECHO_PIN, INPUT);

pinMode(BUZZER_PIN, OUTPUT);


Serial.begin(9600);

}


void loop() {

// Send ultrasonic pulse

digitalWrite(TRIG_PIN, LOW);

delayMicroseconds(2);

digitalWrite(TRIG_PIN, HIGH);

delayMicroseconds(10);

digitalWrite(TRIG_PIN, LOW);


// Read echo time (with timeout for safety)

duration = pulseIn(ECHO_PIN, HIGH, 30000);


// Calculate distance in cm

distance = duration * 0.034 / 2;


Serial.print("Distance: ");

Serial.print(distance);

Serial.println(" cm");


// Turn buzzer on if object is within any amount you want

// The 30 that you see below this line is the amount of centimeters long you want your tripwire to be

if (distance > 0 && distance <= 30) {

tone(BUZZER_PIN, 1000); // Beep at 1 kHz

} else {

noTone(BUZZER_PIN); // Turn buzzer off

}


delay(100);

}

// If you added extra components in the previous step, now is the time to edit in the code for them.

Upload the Code!

Screenshot 2026-02-12 at 9.48.02 PM.png

First plug the board into the device your using. Then press upload!

It should work after that. keep it plugged into a power source and set it next to your doorway for maximum security!