This instructable will show you how to construct a laser tripwire that can twitter and grab an image from a webcam, as well as execute any command you can put in a bash script.
This instructable is actually quite simple and is even suitable as a beginner arduino project. It requires a GNU/linux (or possibly Mac) operating system with the arduino IDE and Processing IDE working properly. This project could also be implemented in Windows if you created a more complex processing application.

Hardware Requirements
Arduino Board
Laser pointer/pen
Light Dependant Resistor
100Kohm Resistor


Software Requirements
Arduino IDE
Processing IDE
Linux OS (I'm using Arch Linux for this project)
Webcam (part of xawtv)

Other Stuff:
Solder and Soldering Iron
Hot Glue Gun
Straw or Ballpoint Pen

Step 1: Connecting the LDR

I needed the LDR and the laser to be in a position where they would not move around so I connected my LDR and resistor directly to the Arduino without a breadboard, but you can do it however you like, below are the photos for soldering and bending them into shape I also included a simple diagram.

I cut the end off of a ballpoint pen so that I could slip it over the LDR to prevent ambient light from affecting the reading, you could also use a straw.
<p>I haven't made any projects for the Arduino. How does Processing cross-compile for the Arduino CPU?</p>
Can it be made on Arduino Uno<br>
Can it be made on Arduino Uno
Can it be made on Arduino Uno
Mdob, can u tell me your codes
Hey dude Mdob. Cam u plz tell me your codes?
Nice project - I am setting one up to take a picture of whichever culprit keeps messing with the lab at work and post there image up on the board of shame. <br> <br>I had to mod the code a little to get it to work on MAC (OSX) 10.6.8 so thought I should upload my code for others to use. Many thanks and here it is. <br> <br> <br>int ledPin = 13; // digital pin to which led is connected <br>int analogPin = 0; // analog pin to which ldr is connected <br>int ldrVal = 0; //variable to store ldr value <br>int threshold = 1000; //variable to store threshold in memory <br> <br>void setup() <br>{ <br> Serial.begin(9600); //set baud rate <br>} <br> <br>void loop() <br>{ <br> ldrVal = analogRead(analogPin); <br> <br> if ( ldrVal &gt; threshold ) <br> { <br> Serial.print(&quot;1&quot;); <br> delay(200); <br> } <br> <br>} <br>
Will this code still work today? I heard that twitter had made it harder to tweet from an arduino. <br> <br>P.s. Im am a complete new person to arduinos and programming so i have no idea!
Here is what I did. I modified some of it a bit. I used the processing code but made it open up a .bat file which used snapz to take a picture and then used a .vbs file to attach that picture and send and email to my gmail account. This was all using windows.This has been a fun project. Now, all I need to do is make it all self-contained. I could possibly use the &quot;$25 Computer&quot; (http://www.raspberrypi.org/) with a camera and put it all in a project box with a laser module. That would be fun. If anybody wants the code that I used just ask me and I will host it.
yes please, followed by an instructable
I do have an instructable up if you look at my account. <a href="http://tinyurl.com/7a2wcoj" rel="nofollow">(Link)</a> I didn't want to go through all of the laser stuff again so I made it activate on login. To adapt it to make it so that it will open up the Send.bat file (Which will start the process to take the picture and send the email) simply replace<br> <br> open(&quot;/home/username/someplace/twitter.trip&quot;)<br> <br> in the processing code with the location of your files. eg.<br> <br> open(&quot;C:\Users\EngineeringChannel\Send.bat&quot;)<br> <br> That is all that you have to modify from my instructable. Also, don't follow the instructions where it says that you have to hide it or make it run on startup. I hope that helps, Good Luck!
Hey, I've tried doing what you did and I made twitter.trip into a .bat file. It runs just fine when I double-click it and/or run it from the command prompt, but open() doesn't seem to be running it. Do you have any ideas as to why it wouldn't be working? Thanks
I have very little experience with Processing so I really don't know. When I tried it (this was quite a while ago) it worked just fine. Maybe somebody who knows a little bit more about Processing could help you out.
ok, thanks
Hi mate great idea would love it if i could get a copy of your source code. cheers Jordan
Can someone please modify this to not use processing? I am new to arduino and have been bashing my head in to make this completely stand alone (no pc needed). I am trying to make it so that it just tweets &quot;laser has been tripped&quot; after the alarm sounds. I have an Arduino Uno with Ethernet shield.
&quot;put twitter.trip into:<br>/home/your_username/&quot; where do i find the /home/my-username? folder ? and which software i will use the arduino or processing to load the script thanks.
you answered your own question, you find it in the HOME folder, as for the other question you can get the software from arduino.cc under downloads
Basic auth is now unsupported by twitter. So you wont be able to use the code from twitter.trip.<br><br>User SuperTweet.net instead. Youre still using curl but supertweet.net acts as a proxy between you and twitter, allowing you to use basic auth. Twitter now uses oAuth which is a pain. For the code below, use your SuperTweet username and password, it is separate from your twitter login. <br><br>#!/bin/bash<br>trip=$(date +'%A %n %d, %l:%M%p' )<br>stat=&quot;[&quot;$trip&quot;] Door has been opened&quot;<br>curl -u USERNAME:PASSWORD -d &quot;status=$stat&quot; http://api.supertweet.net/1/statuses/update.xml --insecure
when I use the Arduino code it does the opposite of what you said it would instead of making a 1 it stops making 1's, is this important?
can you do this with windows?
Nice tutorial, will try this soon!
i tried to upload the code to my arduino and it gave me an error about the line <br>fill(#36ff00) how could i fix this im running windows btw
Hi <br>Excellent project, but it appears now twitter does not support basic authentication when you run curl...what need to be changed in the bash script?<br>Thanks,<br>k
They recently updated Twitter's authentication method, I'll have to rewrite the bash script sometime, but considering I have capstone this semester I may not get around to it :(<br>
Do you think it would be possible to send it to a google buzz or other account instead?
Sweet but looks complicated.
I can't seem to download the files in your 'ible.&nbsp; Every time I click the link it downloads a file with some wierd name and a .tmp extensions.&nbsp; Do you have anywhere else that I could download the code from?
That's weird, Something must be up on instructables end, I'm adding the code in plain text to step 6 right now.<br />
just rename the file extension to pde and it will work
I've had this problem before. Just rename the file to the extension you need. SIlly instructibles.com<br />
Cool and awesome!! I would be tempted to just hook the ldr to my joystick port and cut out the arduino.. I would use freebasic to get info from the joystick port and then call twidge to do the twitter via the shell. Probably use an antique computer running Debian to do all this.
Looking at this, and your tweets, either you are working really late, or a 5am badger or moth is messing your sensor up. Might I suggest a small delay in the code so it triggers after (say) 1/4 of a second?
the ohms resistor is 100K about the LDR&nbsp;radioshack does not have them in stock throughout there website chain
How do you open the twitter.trip file? and Im having a bit of trouble with your instuction, like the code. <br />
Could you be a bit more specific? You can message me with detailed questions too.
Oh, I dont need this anymore. I did it for a school assignment. It ended up not working, BUT we got an 85% on it, which is good lool for it not working lmao.<br />
Nice project. I want to try this one for my first. Where do I purchase the Arduino? I will mount the laser like in the plans. Can you expand on how you used the webcam, zawtv? Perfect choice of linux arch for the os.<br />
I&nbsp;usually get my arduinos from <a href="http://www.sparkfun.com/commerce/product_info.php?products_id=666" rel="nofollow">sparkfun.com</a>,&nbsp; If you install zawtv it will also install the program called &quot;webcam&quot;. If you have problems getting your webcam working start a thread in the <a href="http://bbs.archlinux.org/" rel="nofollow">Arch Linux</a> forums and somebody will get you going, Or post back with specifics and I'll try to help your through any problems, good luck.<br />
Printed my parts list and read Arch Linux wiki &amp; forums plus watched few Youtube how to build the Arch Kernel. Will order Arduino today from sparkfun.com.&nbsp; Thanks!<br />
Build a kernel? I'm not sure about Arch Linux, but I never had to mess with anything like that on Ubuntu. Painless installation, works &quot;out of the box&quot;.<br />
I've never had to compile the kernel in Arch either?<br />
I am purchasing the &quot;Aruuino USB Board&quot; from sparkfun, is this the right one?<br />
1+ for Django<br />
could require alot of code editing, (i dont know as im not an arduino user, although this could convince me otherwise) but could it be linked with just a webcam and used as an intruder alert, getting the webcam to photograph whoever entered your room??<br /> <br /> awesome 'ible<br />
Wouldn't it be more useful to use an infrared laser?&nbsp; The red laser is too easy to notice.<br />
How sensitive does the LDR have to be? WHat were the specifications of the LDR you used?
The one I used is <a href="http://www.sparkfun.com/commerce/product_info.php?products_id=9088" rel="nofollow">this one</a> or one very close to it. (it was in my box of random parts so not 100% sure) The details don't matter so much as long as you get light readings from it. <br /> The laser will be powerful enough to activate it so any basic LDR/Photocell will work. Worst case scenario you may have to adjust the &quot;int threshold=500;&quot; line in the arduino.pde file.
Thanks for posting this here! Do you have any idea what range you can cover with this setup?
&nbsp;The limiting factor is the range of the laser and how good you are at aiming the laser back at the LDR, in theory you could even use multiple mirrors and cover a lot of ground

About This Instructable




More by action_owl:Twittering Laser Tripwire with Webcam Capture Nintendo Keyless Entry System Underwater Microphone (Hydrophone) 
Add instructable to: