Let your LikeLight shine
We’ve been doing a lot of experimentation with the Facebook Like functionality lately. For good reason, it’s all the rage in Social Media! Since Facebook opened up their Graph API we developer types have been able to get all sorts of fun data to play with. One of those bits of data is the Like count for any Facebook object. Person, post, page, etc…That’s cool and all but how could we take that and make it awesomer?
If you know me you know I have a soft spot in my heart for Legos. I think it’s because they’re so great for prototyping physical objects. I don’t manufacture things, I do click blocks together. A plus, most things I deal with on a daily basis are pixelized. Legos are some of the closest physical representation of pixels. So, what if I built a Facebook Like button out of Legos? What if I made it light up every time someone liked redpepper’s Facebook page? Is that even possible? Yes.
Enter Arduino. You’ve probably never heard of these things but do not worry. They’re little microcontrollers. Little tiny motherboards if you will. They’re taking the open source hardware community by storm and are the perfect platform for Physical computing. That is, they allow you to programming commands on a computer that result in real-world interactions.
Arduinos can connect to the internet now which means they can send and receive data online. I set up a script at redpepperlab.com/likelight that returns the number of Likes of any Facebook page. I think it’s pulling Lil Wayne’s at the moment. He gets a lot of Likes let me tell you. Anyway, it’s a simple script of only a few lines that does the entire interaction with the Graph API on behalf of the Arduino.
$json_url ="https://graph.facebook.com/LilWayne";
$json = file_get_contents($json_url);
$json_output = json_decode($json);
$likes = 0;
if($json_output->likes){
$likes = $json_output->likes;
}
echo '?='.$likes;
So, what now? Well, I wire up 4 LEDs to the Arduino, write a little bit of Arduino logic to get it to talk to redpepperlab.com/likelight and put it all together. That’s pretty much it!
EDIT: Download Arduino Script here. Please be nice because it’s come crappy code but it works :) It does polling to the PHP script every 5 seconds, not a real-time socket because that would’ve taken me a lotttt longer to do. The Graph API has a 1 request per second limit from what I understand.
EDIT EDIT: Download Lego Model here. This is v1.0. There are some structural issues that a few extra reinforcement blocks could help with. It’ll work as-is though and is the one used in the video.

