Twittering Laser Tripwire with Webcam Capture

Step 6Now run it.


Now everything should be ready to go!

Run the processing sketch and check your twitter and webcam archive location for the result.


Something is up with the file downloads.
So here's the code, again.

#------------------------
# twitter.trip
#------------------------
#!/bin/bash
user="username"
pass="password"
trip=$( date +'%A %b %d, %l:%M%p' )
stat="laser tripped: "$trip
url=http://twitter.com/statuses/update.xml
result=`curl -u $user:$pass -d status="$stat" $url`
#save webcam pic
webcam
date +'%A %b %d, %l:%M%p' > /home/username/someplace


//------------------------
// processing code
//------------------------
import processing.serial.*;
Serial myPort;
char inBuffer;
int wait, now, timeout = 10000;
boolean hold = false;

void setup() {
  size(200,200);
  println(Serial.list());
  myPort = new Serial(this, Serial.list()[0], 9600);
  fill(#36ff00);
}

void draw() {
 
  while (myPort.available() > 0)
  {
    inBuffer = myPort.readChar();  

    if(inBuffer=='1')
    {     
      if ( !hold )
      {
        fill(#ff0000);
        println("Tripped");
        open("/home/username/someplace/twitter.trip");
        wait = millis();
        hold = true;
      }
    }
  }
 
  now = millis();
   
  if (now > (wait + timeout))
  {
    hold = false;
    fill(#36ff00);
  }
   
  rect(0,0,200,200);
}


//------------------------
// arduino code
//------------------------

int ledPin =  13;
int analogPin = 0;
int ldrVal = 0;
int threshold = 500;

void setup()
{
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, HIGH);
}

void loop()                    
{
  ldrVal = analogRead(analogPin);
 
  if ( ldrVal > threshold )
  {
     Serial.print("1");
     delay(200); 
  }
 
}

« Previous StepDownload PDFView All StepsNext Step »
3 comments
Jul 12, 2011. 11:29 AMCatch_22_ says:
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
Jun 13, 2011. 10:56 AMtranoxx says:
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?
Sep 11, 2010. 5:48 AMyoyojoeco says:
Do you think it would be possible to send it to a google buzz or other account instead?

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!
36
Followers
4
Author:action_owl