twitterpop - Code

Recently I’ve been working on a popularity meter which searches twitter and displays a bar graph of the popularity of the search term on an LED Matrix driven by an Arduino. It currently relies on a PHP script on my webserver to do the actual twitter search and the arduino reads the page via ethernet and then displays the number on it bar graph.

The PHP script searches twitter receiving the results as a JSON feed and counting the results, this is just a basic script I threw together and is still very much work in progress as if there are more than ten results the arduino gets a bit confused. This is an abbreviated version of my code which is still functional.

$q = '%40chemicaloliver';

$curl = curl_init();

curl_setopt($curl, CURLOPT_URL, ''.$q.'');

$result = curl_exec($curl);

$json_result = json_decode($result);
$count = 0;

foreach ($json_result->results as $res)

echo $count;

This searches for replies to my posts and displays in a number in a minimal html page.

The arduino then reads this page every time its main loop is executed and adds a new bar to the LED bar graph using the following code and using the TimerOne library. The full sketch can be downloaded here.

More information about the hardware will be included in a later blog post.