The Arduino source.
The python source.
Schematic diagram of the Arduino to LED cube connections.
LED cube controlled by an Arduino board, that can receive commands over serial. There are only 13 available pins for 27 LEDs, so I had to play some tricks to get be able to access each individual LED. The program then pulses through each layer at 30Hz, using persistence of vision to display the entire cube lit up. As a result, the cube allows any number of its LEDs to be on at once. The interface is over a serial port, which is itself over USB. The protocol is a simple list of the state of all 27 LEDs, so a program can send an entire frame at once to the cube.
Now for the interesting part, I grab tweets within a geographic region and compute the sentiment of the tweet based on the words used. I first had to run it through a dictionary that unfortunately discards a lot of tweets due to bad spelling. The results include 3 numbers representing how happy/sad, active/passive, or dominant/submissive the tweet is. I then plot those numbers on the cube. If a tweet is very happy, passive and submissive, it will be on one corner. If it is sad, active and dominant, it will be at the opposite corner. I call it the “Hulk Smash” corner.
Here’s something interesting. I gathered tweets from New York City, Minneapolis and Amherst, MA and compared their sentiments. Overall, the average was remarkably similar, indicating that the median tweets sentiment appear to be homogenous across different regions. The standard deviation varied a bit. Amherst seemed a bit bipolar.
I was playing with the TI Metawatch, trying to get the raw readings from the accelerometers. This is what I used.
- Firmware from the Version0.9 branch on GitHub
- Enabled the accelerometer application by declaring compiler define “ACCELEROMETER_DEBUG”
- Built and flashed with the TI CCS 5.1.1 Development Environment
- Python code running on a MacBook Pro from JoeHughes’ branch at https://github.com/joehughes/PyMetaWatch
- Commented out the button section, cause it’s disabling them and that’s really annoying.
Here’s a sample output:
Received [ e0 01 e0 08 20 02 00 fd 9d d0]
According to the Firmware design guide, the metawatch has a Kionix KXTF9-4100 or KCTF9-1026. I pulled the datasheets here.
- The 4100: http://www.kionix.com/Product-Specs/KXTF9-4100%20Specifications%20Rev%206.pdf
- The 1026: http://www.kionix.com/Product-Specs/KXTF9-1026%20Specifications%20Rev%206.pdf
I am running with 12bit resolution at 25Hz. I first moved along the Z axis (blue), then Y axis (green), then X axis (red). You can see the independent blips along the axes. I then swung the watch in a circle and put it on the table. I had to do some fiddling with 2’s complement conversions and a had a nasty nibble bug of mine, but overall it was pretty straight forward. I might fork Travis Goodspeed’s python code to put my code in there when I get it cleaned up. In the meantime the code is downloadable at the bottom. Off the top of my head, I think I am getting around 3 hours of battery life with that configuration.
For more detail: Arduino Tweeter sentiment LED cube