You deserve something nice.

All we need is a simple circuit that reads analog input from a pressure sensor.

The concept is simple: Hook up the circuit and leave the pressure sensor on a table. Run the program and wait.

When someone places an item on the table on top of the pressure sensor, the program will report it to Twitter. “Hey, there’s something here!” it will say. Then it’ll wait.

After a while, it’ll start to send out little encouragements to its audience. “Hey, this is pretty heavy. It might be expensive. Go ahead. Take it. You deserve something nice.” It will continue to goad its readers into stealing the item until the item is removed, at which point it’ll say something along the lines of “Oh, welp, it’s gone. You snooze you lose.” It’ll then lie in wait of the next item.

Go on. Take it!

The following code serves as the base for the program.

 

import processing.serial.*;
import cc.arduino.*;

Arduino arduino;

static String OAuthConsumerKey = “ipBgVE4kIVANsflVUXBglA”;

static String OAuthConsumerSecret = “cHeE4Kv2BbV0x1Uc1LfeVdUQzSBaRUiiFZFoUr7Ss”;
static String AccessToken = “974484246-q6Vxax2aSf5cUyYykItVLz1dBbUK0RevizhXicsA”;
static String AccessTokenSecret = “N5F9cMO651qe3pZNT1z7SXS7KZZ769hRBQ24o8J8U”;

int pressurePin = 2;
int timer = 0;

String myTimeline;
java.util.List statuses = null;
User[] friends;
Twitter twitter = new TwitterFactory().getInstance();
RequestToken requestToken;
String[] randomNewThing = new String[3];
String[] randomGoneThing = new String[4];
String[] randomStealIt = new String [5];

int prevPressure = 700;

void setup() {
randomNewThing[0] = “Oooooh! Someone left something here!”;
randomNewThing[1] = “Wait, wait, hold the phone… There’s something here!”;
randomNewThing[2] = “Good golly, lookee here! Someone left something on the table.”;

randomGoneThing[0] = “Oh, well, there it goes… that’s too bad.”;
randomGoneThing[1] = “Welp, you snooze you lose. It’s gone.”;
randomGoneThing[2] = “No no no, wait, where’d it go?”;
randomGoneThing[3] = “I feel… a great emptiness. Oh, no, wait, that was just the really amazing thing being lifted off the table and taken away.”;

randomStealIt[0] = “Hey. I had a thought. You could take this. No one would know.”;
randomStealIt[1] = “Come and take it. It’s really cool. And shiny. Probably expensive. You know you want it.”;
randomStealIt[2] = “Wow, I gotta say, this is fancy. You could probably sell it for quite a pretty penny.”;
randomStealIt[3] = “You deserve something nice. Go on. Take it. For you.”;
randomStealIt[4] = “This would really match the decor in your living room. You could hang it on your mantle. Like a moose head. Only better.”;

size(100,100);
background(0);

arduino = new Arduino(this, Arduino.list()[0], 57600);
arduino.pinMode(pressurePin, Arduino.INPUT);

connectTwitter();
}
void draw() {
int pressureValue = arduino.analogRead(pressurePin);

background(0);

if(prevPressure > 0 && pressureValue == 0) {
int randomChoice = (int)random(3);
sendTweet(randomNewThing[randomChoice]);
}
else if(prevPressure == 0 && pressureValue > 0) {
int randomChoice = (int)random(4);
sendTweet(randomGoneThing[randomChoice]);
timer = 0;
}
else if(timer > 500 && pressureValue == 0){
int maybeSteal = (int)random(5000);
println(“maybesteal: ” + maybeSteal);
if(maybeSteal > 4998){
int randomChoice = (int)random(5);
println(“choice number: ” + randomChoice);
sendTweet(randomStealIt[randomChoice]);
}
}
timer++;
prevPressure = pressureValue;
}
void connectTwitter() {

twitter.setOAuthConsumer(OAuthConsumerKey, OAuthConsumerSecret);
AccessToken accessToken = loadAccessToken();
twitter.setOAuthAccessToken(accessToken);

}

void sendTweet(String t) {

try {
Status status = twitter.updateStatus(t);
println(“Successfully updated the status to [” + status.getText() + “].”);
} catch(TwitterException e) {
println(“Send tweet: ” + e + ” Status code: ” + e.getStatusCode());
}

}

private static AccessToken loadAccessToken(){
return new AccessToken(AccessToken, AccessTokenSecret);
}

Comments are closed.