3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Arduino Laser Tripwire

Arduino Laser Tripwire
«
  • DSC02881.JPG
  • DSC02876.JPG
  • DSC02877.JPG
  • DSC02878.JPG
The Arduino is great, you can make it do pretty much anything you want.

I wanted a tripwire. This is just the circuit and the code, you can use it for quite a few things, like a trigger for a camera, or you could make it shut down your computer if someone crosses it.

When I have the time, I want to hook it up to an electric airsoft gun with a relay and have it shoot you when you break the beam. I suppose I'll add to the Instructable when that happens.

So let's start!
 
Remove these adsRemove these ads by Signing Up
 

Step 1Components Needed

Components Needed
This is what you need for this project:

-Arduino
-10k Resistor
-Photo resistor (Practically any value will work, the program will just need to be changed slightly)
-Laser Pointer
-Jumper Cables
-Alligator clips
« Previous StepDownload PDFView All StepsNext Step »
68 comments
1-40 of 68next »
May 1, 2010. 8:15 PMhill says:
 hey there thanx for this awesome tut but when i try to run the sketch in arduino its says "error: redefinition of 'void setup()'

and wont run

please help ?

thanx
May 27, 2010. 6:06 PMArchive555 says:

If you just copy and paste the code has there, it won't work.

void setup() {
pinMode(4, OUTPUT);
pinMode(13, OUTPUT);
}

void loop(){
digitalWrite(4, HIGH);
if(analogRead(0) < 750){
digitalWrite(13, HIGH);
} else{
digitalWrite(13, LOW);
}
}

void setup() {
pinMode(4, OUTPUT);
Serial.begin(9600);
}

void loop(){
digitalWrite(4, HIGH);
Serial.println(analogRead(0));
}

Those two seperate sections of code need to be combined, as thse are both programs in their own right. From memory it should be something similar to this:

void setup() {
pinMode(4, OUTPUT);
pinMode(13, OUTPUT);
Serial.begin(9600);
}

void loop(){
digitalWrite(4, HIGH);
if(analogRead(0) < 750){
digitalWrite(13, HIGH);
} else{
digitalWrite(13, LOW);
Serial.println(analogRead(0));
}
}

Please not though that each of those segments of code were designed for a seperate task; one to simply trigger an LED when the beam is broken, the other to send data from the LDR to the computer so that Processing may be used. The combined code does both of these tasks, although you pobably don't need the serial transfer section if you had an error like that that you couldn't fix. Most of the people who will want to try this will be content with the first segment of code; that is, just turn on an LED or similar device when the beam is broken. The second piece of code is for more advanced users who wish to create a monitoring program in Processing (probably not you).

Hope this helped.
       -Archive

Jan 5, 2011. 8:33 AMfrankhiggins says:
Hi, this sounds great and perhaps just what I'm looking for. I'm doing a project at university using Arduino and Processing and want to use a camera triggered by motion to produce an effect like the one shown below (by Magritte).
What I want to achieve is to have a computer screen using the mirror function in Processing and camera that is triggered by a person entering the space. Ideally the camera should track the person so that they can never see their own face in the mirror but that might be a bit ambitious for my skils / knowledge level at present.

Thanks in anticipation,

Frank
May 23, 2012. 7:57 PMidee17 says:
hey you should check out the website http://projectsentrygun.rudolphlabs.com/
from the motion and tracking thing. I bet you could modify his code for what your wanting to do.
Apr 16, 2012. 1:09 AMgallactronics says:
Hi! This is a wicked LASER project. Actually you can make something very useful this circuit. You can make a LASER counter and use it for counting people or objects on a conveyor! And you don't even require an Arduino for it. There is a step by step guide on how to make a LASER trip wire counter in this site:

http://gallactronics.blogspot.in/2011/11/laser-people-counter.html

Thanks
Jan 22, 2012. 7:07 PMcpoplawski says:
Can someone add in the ability for it to tweet when the alarm gets tripped? That would make it sick!
Feb 2, 2010. 5:21 AMVrIgHtEr says:
it can be modified to be kind of self calibrating. Just a software thing xD. Turn on the laser, read the value, turn off the laser and read the value again, choose a threshold somewhere in between the two values, turn the laser back on and start the main loop
Apr 17, 2011. 7:36 AMNoseyNick says:
Another common technique is to do this continuously - deliberately strobe the laser (possibly so fast that PoV makes it look continuous) and alarm when you can no longer "see" your strobing. Then day/night variations, lights on/off, and even people waving torches around won't affect it.
Aug 13, 2011. 9:57 AManonymouse197 says:
I love the idea, I'm breaking out the old laser pointer now! :)
Apr 17, 2011. 2:19 PMiEdd says:
More importantly, people waving a laser around won't affect it. You can't simply hold a laser pointer on the LDR as you walk through the beam.

You're onto a very smart idea to make it frequency dependent. Then there would be a good reason to use the Arduino. (The project as it is can be done with a transistor, trimpot, couple of resistors, LDR and LED)
Apr 17, 2011. 8:10 AMVrIgHtEr says:
Interesting idea. 10x :D
Jul 28, 2011. 10:35 AMnotgeek says:
What kind of Arduino should I get for this?
Jul 28, 2011. 10:32 AMnotgeek says:
Where is the video?
Jul 2, 2011. 3:12 PMNCGeek says:
I think this is a great idea, and I have just the right application for it. Problem is, I am having trouble finding a photo resistor like the one in your video. I have some photo resistors I got from Adafruit, but they are tiny, and I am afraid I will have difficulty with allignment. Could you recommend where I could get a larger one, like you have?
Apr 19, 2011. 2:19 AMJOBGG says:
I personally think that an Arduino is overkill, one proably could do that with an LDR. Even the idea with a oscilator should be possible to implement without an arduino.
I do think that's a great instructable though.
Jun 27, 2011. 12:58 PMAmerican Eagle says:
I disagree... The Arduino allows you to do hundreds of different things JUST with this concept.
Apr 18, 2011. 11:44 PMElectrified Geek says:
Hey, where could I get the Arduino thing? Could i find one on eBay?
Apr 17, 2011. 10:47 AMMCUman says:
I built a football trainer years ago that used IR emitters modulated at something like 35KHZ aimed at tuned receivers from Sharp at the same freq. There were 8, multiplexed in an array. Both emitters and receivers were placed in 2" tubes and placed 6' apart from each other, forming a 6' X 6' opening. The brain was a Motorola HC705J1A MCU that fed a main MCU HC705C8 over one I/O line. It worked very well in bright sun light. The fun part was the power usage was very low as only one IR led was ever ON at any given moment. I ran some tests and was able to get a distance of 20' separation outdoors using nothng more than run-of-the-mill IR LEDs. The trick was using those tubes.
Apr 17, 2011. 8:27 AMbetwys1 says:
If possible add a weak lens as a beam expander, so the laser spot just covers the active area of the photo resistor. That will give much greater sesistivity, and will propbably ease even remove the need for calibration altogether.

Brian Whatcott
Apr 12, 2011. 5:59 PMkellergrrl says:
would an arduino NANO 3.0 work?
Mar 12, 2011. 2:33 PMtransuranic says:
it looks like your using the uno.I guess ill use the uno to.
Mar 18, 2011. 1:03 PMChowmix12 says:
This was published in 2008.. the UNO was released 2 years after.. .It doesn't matter which board you use.
Mar 12, 2011. 2:30 PMtransuranic says:
Does it matter wich arduino you use?
Jan 10, 2011. 2:13 AMlemon rind says:
He He... If someone could rig this so it shot the person with something (nerf gun? Paintball?) when set off, they would be a legend...
Dec 15, 2008. 8:11 PMOra says:
Great idea! As an improvement, could you add a second photoresistor that just takes a reading of the ambient light in the room, and use that reading instead of having to calibrate the arduino?
Dec 23, 2010. 1:40 AMDIY-Guy says:
Simple solution may not require additional electronics-
Place the sensor at the back end of a black tube to block ambient light.
Mar 5, 2009. 4:43 PMwiren says:
Even better is to add a startup test code to setup(), that will measure when laser is on and off to different variables, then the variables can be used everywhere.. :) Hw costs money, software cost our time :)
Jun 25, 2009. 1:34 PMMechroneal says:
The catch to that is if the system is on for several hours, daylight changing could cause it to set off. Could you set it up so the system: 1-Checks the sensor with no laser 2-Turns the laser on 3- Checks for a fault (tripped laser) 4- Cycles off the laser and repeats? I would think something like this repeating several times a second would be accurate enough to detect faults, it would increase the battery life of the laser, and would not be set off by changes in lighting caused by the sun moving. Does this make sense?
Mar 4, 2009. 1:31 PMamando96 says:
how could you do that? like:

if(analogRead(0) = analogRead(1)) {
digitalWrite(13, LOW);

it doesnt work though! :S but the principle is close right? lol
Apr 26, 2010. 8:17 PMOra says:
I just completed a modified version of this. I modified the original code to check the value of the photoresitor with the laser on and then off, it averages the values, and then checks if the value of the photoresistor with the laser on is less than that value. If the beam is broken, the arduino triggers the button on a wireless doorbell using an optoisolator, which in turn chimes the door bell.
Jan 27, 2009. 5:32 PMgeeklord says:
You think that that would work with a 2N3904? I've been wanting to do that for a while now but have worried about takin apart my airsoft gun, because I have taken apart the electric ones before and have had problems putting them back together with all the uncooporitive springs...
Feb 1, 2009. 1:09 PMgeeklord says:
yeah, I'm having trouble with learning how to interface an arduino with RC servo motors.
Feb 2, 2009. 9:22 PMgeeklord says:
okay, so is it just one pulse? I've heard the pulses are anywhere from 1-2 milliseconds. And what code do you use with the arduino to do that?
Feb 5, 2009. 4:37 PMgeeklord says:
then wouldn't you need a variable called pulseWidth?
1-40 of 68next »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
8
Followers
1
Author:Login258(Check out my Youtube Channel!)