Twittering Laser Tripwire with Webcam Capture by action_owl
Featured

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

Optional:
  Webcam
  Breadboard


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


Other Stuff:
Mirror
Solder and Soldering Iron
Wire
Hot Glue Gun
Hacksaw/Knife
Straw or Ballpoint Pen
arduino.pde359 bytes
twitter.trip270 bytes
 
Remove these adsRemove these ads by Signing Up

Step 1: Connecting The LDR

PIC_0156.JPG
1.JPG
2.JPG
3.JPG
4.JPG
5.JPG
7fin.JPG
6fin.JPG
PIC_0157.JPG
diag.png
PIC_0159.JPG
PIC_0161.JPG
 
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.
1-40 of 56Next »
DidyDoddie says: Oct 27, 2012. 10:37 AM
Will this code still work today? I heard that twitter had made it harder to tweet from an arduino.

P.s. Im am a complete new person to arduinos and programming so i have no idea!
Mdob says: May 17, 2011. 5:48 PM
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 "$25 Computer" (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.
EngineeringChannel says: Mar 27, 2012. 7:54 AM
yes please, followed by an instructable
Mdob says: Apr 2, 2012. 7:25 AM
I do have an instructable up if you look at my account. (Link) 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

open("/home/username/someplace/twitter.trip")

in the processing code with the location of your files. eg.

open("C:\Users\EngineeringChannel\Send.bat")

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!
wallBme says: May 28, 2012. 8:53 PM
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
Mdob says: May 29, 2012. 4:56 AM
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.
wallBme says: May 29, 2012. 5:16 AM
ok, thanks
jparfoot says: Oct 15, 2011. 1:22 AM
Hi mate great idea would love it if i could get a copy of your source code. cheers Jordan
cpoplawski says: Jan 22, 2012. 7:00 PM
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 "laser has been tripped" after the alarm sounds. I have an Arduino Uno with Ethernet shield.
riddik001 says: Dec 1, 2011. 7:22 AM
"put twitter.trip into:
/home/your_username/" where do i find the /home/my-username? folder ? and which software i will use the arduino or processing to load the script thanks.
dudesurge says: Dec 24, 2011. 3:18 PM
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
Catch_22_ says: Jul 12, 2011. 11:29 AM
Basic auth is now unsupported by twitter. So you wont be able to use the code from twitter.trip.

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.

#!/bin/bash
trip=$(date +'%A %n %d, %l:%M%p' )
stat="["$trip"] Door has been opened"
curl -u USERNAME:PASSWORD -d "status=$stat" http://api.supertweet.net/1/statuses/update.xml --insecure
tranoxx says: Jun 13, 2011. 10:56 AM
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?
polishdude says: Feb 19, 2011. 11:40 PM
can you do this with windows?
habzbah says: Oct 24, 2010. 3:15 PM
Nice tutorial, will try this soon!
ledfreak01 says: Sep 22, 2010. 6:45 PM
i tried to upload the code to my arduino and it gave me an error about the line
fill(#36ff00) how could i fix this im running windows btw
kenkoknz says: Sep 9, 2010. 3:40 PM
Hi
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?
Thanks,
k
action_owl (author) says: Sep 19, 2010. 8:17 PM
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 :(
yoyojoeco says: Sep 11, 2010. 5:48 AM
Do you think it would be possible to send it to a google buzz or other account instead?
yoyojoeco says: Sep 9, 2010. 6:21 AM
Sweet but looks complicated.
Computothought says: Aug 4, 2010. 3:07 AM
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.
_soapy_ says: Jul 4, 2010. 3:29 PM
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?
stanuszekj says: May 10, 2010. 11:20 AM
the ohms resistor is 100K about the LDR radioshack does not have them in stock throughout there website chain
sardines454 says: Jan 26, 2010. 1:04 PM
I can't seem to download the files in your 'ible.  Every time I click the link it downloads a file with some wierd name and a .tmp extensions.  Do you have anywhere else that I could download the code from?
Junkyard John says: Apr 12, 2010. 2:32 PM
I've had this problem before. Just rename the file to the extension you need. SIlly instructibles.com
action_owl (author) says: Feb 1, 2010. 7:32 PM
That's weird, Something must be up on instructables end, I'm adding the code in plain text to step 6 right now.
mman1506 says: Sep 6, 2010. 2:41 PM
just rename the file extension to pde and it will work
yosama101 says: Jan 19, 2010. 4:48 PM
How do you open the twitter.trip file? and Im having a bit of trouble with your instuction, like the code.
action_owl (author) says: Feb 1, 2010. 7:33 PM
Could you be a bit more specific? You can message me with detailed questions too.
yosama101 says: Feb 2, 2010. 4:48 PM
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.
coolio49085 says: Jan 7, 2010. 2:17 PM
1+ for Django
Alpvax says: Jan 7, 2010. 1:40 PM
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??

awesome 'ible
jridley says: Jan 7, 2010. 11:35 AM
Wouldn't it be more useful to use an infrared laser?  The red laser is too easy to notice.
yosama101 says: Jan 5, 2010. 7:50 AM
How sensitive does the LDR have to be? WHat were the specifications of the LDR you used?
action_owl (author) says: Jan 5, 2010. 9:22 AM
The one I used is this one 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.
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 "int threshold=500;" line in the arduino.pde file.
renehug says: Jan 4, 2010. 6:50 AM
Thanks for posting this here! Do you have any idea what range you can cover with this setup?
action_owl (author) says: Jan 5, 2010. 7:10 AM
 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
t4kitty says: Jan 4, 2010. 4:29 PM
can you follow these steps on window

t4kitty says: Jan 4, 2010. 7:01 PM
windows*
Buzzsushi says: Jan 4, 2010. 3:36 PM

do you have like a radioshack part number for the LDR?
And how many ohms is the resistor?

1-40 of 56Next »
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!