If for some reason the ustream embed does not appear, refresh the page.
UPDATE: The SocialBot9000 device has returned to meet it’s parts box. Look for something new and exciting… when I think it up. I am leaving the rest of the post as is.
Display Your Message on the SocialBot9000. (UPDATE: SEE ABOVE NOTE)
- Enter your message in the form below.
- Press “Tweet”. You will be redirected to twitter.
- If you are not logged in you will be promoted to do so.
- You will see your message with the required syntax ready to tweet.
- tweet your message.
I was watching Ben Heck’s show on revision3. For Valentines day he made a device that would show love messages sent via twitter. Ben Heck being a nerd master, with more fu than I, WAY over complicated the project. It had custom microcontrollers, php, serial interfaces and all kinds of
crap cool stuff. So I thought to myself, I can rebuild it simpler, smaller and with basically the same hardware setup I just used for my Arduino Thermostat.
- Arduino Uno
- Ethernet Shield
- LCD Display
- Jumper wires
In short we need to do the following:
- Build Hardware
- Search twitter for whatever we want to display
- Put it on the screen (Arduino Ethernet Client)
- Provide some sort of UI to let the world play with Socailbot900
Building the Physical SocialBot9000
If you have the hardware I listed above this is going to be really easy. This part of the project took me less than 30 min.
- Insert Ethernet Shield into Uno
- Insert Proto Shield into Ethernet Shield
- Connect jumper wires
- Insert LCD
- Start the harder part (well for me anyway)
There is a lot of information on how to hook up LCDs so I won’t go too deep. The real complication here is not conflicting with the Ethernet. So check out the source (link bellow) for the pin configuration I used.
Here is a cheat sheet:
|3||Pot (middle pin)|
|4||Arduino Digital 2|
|6||Arduino Digital 3|
|11||Arduino Digital Pin 4|
|12||Arduino Digital Pin 5|
|13||Arduino Digital Pin 6|
|14||Arduino Digital Pin 7|
Twitter provides a handy API thing to easily extract data and BAM:
That will get ya where you want to go. So I wrote a PHP page that curls that URL, cuts out the message and gets is ready for the socialbot. So the PHP looks like this:
$ch = curl_init(“http://search.twitter.com/search.json?q=socialbot9000″);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_GET, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
$start = strpos($output, “start”) + 6;
$end = strpos($output, “end”);
$tweet = substr($output, $start, $end-$start);
Arduino Ethernet Client:
If you read this bildr turtorial you are 90% there.
There are a few important notes.
- I am going crazy with the OLs in this post.
- Arduino 1.0 supports DHCP, so you don’t have to assign the Arduino a static. Because this is a client situation that works out well. EXCEPT when you are on a network where the DHCP server and the Arduino don’t seem to talk, then its back to static land. Moral of the story: try DHCP first.
- To keep this really simple I would have loved for my twitter searching part to be on the same server as everything else. However, my shared hosting account does not have an IP so I had to host this part somewhere where I could pretend. Like a linux machine in a closet somewhere in the world.
You can download and play with the Arduino code here (right click, save as, bla, bla, bla, if you got this far I really don’t need to tell you).
Provide some sort of UI to let the world play with Socailbot900
For now that UI is this post, the ustream and the iframed form. The ustream is coming from a webcam/netbook in a closet. Earth shattering I know.
I am pretty sure my form could use some help, but it was not the focus of this project.
The one cool thing that is interseting to note is how to set up a tweet, making it easy for people to interface with the SocialBot9000.
First the syntax. My twitter search of for “socialbot9000″. So twitter will return any tweet where its mentioned. Then I look for “start” and “end”. So for a message to appear you need to tweet something like “@socialbot9000 start I like cats (not really) end”. I am a online marketer for a living and I can tell you trying to get people to set that up for themselves will be a pain and rife with errors. Enter the form.
So the form submits you message to a php thing that concatenates it with the rest of the syntax. There is client side processes to make sure the message is less than 30 chars. Because anything more is just useless.
So my PHP for the UI should looks like this:
$tweet = $_POST["limitedtextarea"];
header( ‘Location: https://twitter.com/intent/tweet?text=@socialbot9000 start ‘.$tweet.’ end’ );
So in here is a marketing pro-tip. Want to set up a message that people can quickly and easily tweet. Just use the URL above. A fine example would be this.