Components and supplies
Ultrasonic Sensor - HC-SR04 (Generic)
Arduino Nano R3
Male/Male Jumper Wires
Buzzer
Tools and machines
Computer
Apps and platforms
Arduino IDE
Project description
Code
Tripwire with Nano and Ultrasonic
c_cpp
Tripwire with Nano and Ultrasonic
c_cpp
Downloadable files
How to make the circuit
How to make the circuit
Comments
Only logged in users can leave comments
Anonymous user
2 years ago
What is the working distance of the tripwire? I would like to know if someone is walking up our hilly driveway, not if they are already on my front porch.
Anonymous user
2 years ago
If you change the line "if (distance <= distancefirst - 5)" to something like "if (distance <= distancefirst - 60)" it works at around two feet. Play with the last number. Maybe 50 for your three feet. Hope that helps
Anonymous user
2 years ago
I was thinking the same and found this. This economical sensor provides 2cm to 400cm of non-contact measurement functionality with a ranging accuracy that can reach up to 3mm. So I guess it has a maximum range of 4 meters.
wbowl4
2 years ago
What you want for that is a more powerful sensor. This might be a bit tricky to wire though, and you'll need more code.
Anonymous user
2 years ago
this is the best progect
Anonymous user
2 years ago
hey... doing a school project with this... does it send a message to phone or how does it communicate the alarm?
gamemaster8245
2 years ago
The code is saying that when there is something that alters the distance the sound can travel, the sensor sends a signal that allows power to be accessed from pin D3. Basically, when something gets in the way of the sound that the ultrasonic sensor sends out, it tells the Nano to allow power to pin D3, which then activates the alarm, allowing the alarm to follow it's programming, make sense? Hope this helps, gamemaster8245 😀
Anonymous user
2 years ago
What power supply are you using and how long does it last? Did you add a shield to set an alert to android or windows etc? If so how?
DeepDarck
2 years ago
Hello... Whith this sensor and schematics I can use to a truck, on the fuel tank like anty-thief? The fuel tank of a truck is long about 3 meters, and is in open space. I can use somting like this, to have a liniar perimeter tripwire? Sorry for the language. All the best.
Anonymous user
2 years ago
This would be great for local high school and middle school track programs for a Fault line for Long and Triple jump. I wanted to create one years ago, before I heard of arduino.... I was going to use a garage door sensor. This would be perfect. too bad my daughter isn't involved anymore. Quick build, could be powered by battery (I assume) for portability.
Anonymous user
2 years ago
Hi, I just spent today building this project and may I say thank you for posting it. It is working almost perfectly with one exception the sensor distance is too great for my intended purpose, how could I lower the distance to about three feet to cover my front and rear steps leading up to my doors, other wise it would be perfect for a driveway sensor (at least in my case). I did look at the code but I can not figure out what type of math you are using. The only permanent change I made was to comment out line 30 and uncomment line 31 to switch to inches, Also I tried making changes to line 38 but it did not seem to make a difference. Could you offer any advice on how to change the sensor distance? Thank you
Anonymous user
2 years ago
Thank you for the help. I tried you suggestion half a dozen times but it didn't work. Right now it has an approximate range of about 8 feet and around my place too much happens within 8 feet of my front porch, that's why I need it trimmed down to 3 foot, the width of my steps only.
Anonymous user
2 years ago
I forgot to mention that I didn't have an Arduino Nano so I used a 3v Arduino Pro Mini.
Anonymous user
2 years ago
If you change the line "if (distance <= distancefirst - 5)" to something like "if (distance <= distancefirst - 60)" Or maybe 90, it depends on your base reading I am assuming because sometimes 60 works for me and sometimes 90 works. I have it setting in front of my laptop and if someone tries to use it, it sounds the alarm. Hope that helps
wbowl4
2 years ago
Ok. For now, try this. Position the IT wherever you want it, so that the sensor is pointing at the target. Now press the reset button. It should work to the distance that it is now. Thanks, Will_the_Star
Anonymous user
4 years ago
I am trying to understand the code. I am very new to this and I don't understand why the sensor is able to tell pin d3 to make the buzzer go off? I want to know, because I want to try and edit the code so that I can make lights and a sound go off.
gamemaster8245
2 years ago
The code is saying that when there is something that alters the distance the sound can travel, the sensor sends a signal that allows power to be accessed from pin D3. Basically, when something gets in the way of the sound that the ultrasonic sensor sends out, it tells the Nano to allow power to pin D3, which then activates the alarm, allowing the alarm to follow it's programming, make sense? Hope this helps, gamemaster8245 😀
Lucky_Break
6 years ago
This would be great for local high school and middle school track programs for a Fault line for Long and Triple jump. I wanted to create one years ago, before I heard of arduino.... I was going to use a garage door sensor. This would be perfect. too bad my daughter isn't involved anymore. Quick build, could be powered by battery (I assume) for portability.
proteam111
6 years ago
What power supply are you using and how long does it last? Did you add a shield to set an alert to android or windows etc? If so how?
Anonymous user
6 years ago
hey... doing a school project with this... does it send a message to phone or how does it communicate the alarm?
gamemaster8245
2 years ago
The code is saying that when there is something that alters the distance the sound can travel, the sensor sends a signal that allows power to be accessed from pin D3. Basically, when something gets in the way of the sound that the ultrasonic sensor sends out, it tells the Nano to allow power to pin D3, which then activates the alarm, allowing the alarm to follow it's programming, make sense? Hope this helps, gamemaster8245 😀
Anonymous user
6 years ago
this is the best progect
DeepDarck
6 years ago
Hello... Whith this sensor and schematics I can use to a truck, on the fuel tank like anty-thief? The fuel tank of a truck is long about 3 meters, and is in open space. I can use somting like this, to have a liniar perimeter tripwire? Sorry for the language. All the best.
Anonymous user
6 years ago
Hi, I just spent today building this project and may I say thank you for posting it. It is working almost perfectly with one exception the sensor distance is too great for my intended purpose, how could I lower the distance to about three feet to cover my front and rear steps leading up to my doors, other wise it would be perfect for a driveway sensor (at least in my case). I did look at the code but I can not figure out what type of math you are using. The only permanent change I made was to comment out line 30 and uncomment line 31 to switch to inches, Also I tried making changes to line 38 but it did not seem to make a difference. Could you offer any advice on how to change the sensor distance? Thank you
Anonymous user
2 years ago
Thank you for the help. I tried you suggestion half a dozen times but it didn't work. Right now it has an approximate range of about 8 feet and around my place too much happens within 8 feet of my front porch, that's why I need it trimmed down to 3 foot, the width of my steps only.
Anonymous user
2 years ago
I forgot to mention that I didn't have an Arduino Nano so I used a 3v Arduino Pro Mini.
Anonymous user
2 years ago
If you change the line "if (distance <= distancefirst - 5)" to something like "if (distance <= distancefirst - 60)" Or maybe 90, it depends on your base reading I am assuming because sometimes 60 works for me and sometimes 90 works. I have it setting in front of my laptop and if someone tries to use it, it sounds the alarm. Hope that helps
wbowl4
2 years ago
Ok. For now, try this. Position the IT wherever you want it, so that the sensor is pointing at the target. Now press the reset button. It should work to the distance that it is now. Thanks, Will_the_Star
Anonymous user
6 years ago
What is the working distance of the tripwire? I would like to know if someone is walking up our hilly driveway, not if they are already on my front porch.
Anonymous user
2 years ago
If you change the line "if (distance <= distancefirst - 5)" to something like "if (distance <= distancefirst - 60)" it works at around two feet. Play with the last number. Maybe 50 for your three feet. Hope that helps
Anonymous user
2 years ago
I was thinking the same and found this. This economical sensor provides 2cm to 400cm of non-contact measurement functionality with a ranging accuracy that can reach up to 3mm. So I guess it has a maximum range of 4 meters.
wbowl4
2 years ago
What you want for that is a more powerful sensor. This might be a bit tricky to wire though, and you'll need more code.
Ultrasonic Tripwire | Arduino Project Hub
luke_dovzik
2 years ago
Does this work with Arduino UNO R3?