Featured on hackaday, gizmodo and hacked-gadgets
The cube is driven by three 1.5V small button cells (which are sold here as batteries for EasyPark computerized parking ticket). The brain of this gadget is a ATmega168. The ATmega168 is programmed using avr-gcc and avr-libc. The MCU is connected to the matrices using a ULN2008 as a current sink and a 74LS164 as led driver. For extra fun I pulled a speaker from a Nokia mobile phone and connected it as well.
The whole circuit is soldered on a perf-board. All of the connections were made by soldering wire-up wires. I hate wrapping wire-ups and when I built this thing I wasn't capable of producing double-sided PCBs, so that's what I chose. I covered the wire-side of the PCB with perspex in order to protect it from tearing apart (which happened quite a lot!). You can see the wire-up work here:
The fun part was connecting the MMA7260QT to the rest of the circuit. The accelerometer is very small and comes packed as a QFN16. The method I chose to connect the chip is as follows:
Certainly not a job for the faint of heart. You can see the result in this picture:
I programmed the whole thing in C, using the avr-gcc toolchain in AVR-Studio. I needed to program a display-driver that go over all of the roles periodically and pushes the proper bitmask to the serial shift register that drives the LEDs.
I also put in a menu system. When powering up the device it lets the user to select an application. The few applications I programmed so far are the dice application, and a “display test” application which scrolls lines accross the screen. This is useful to find a faulty wiring in the display…
The dice is very simple. First you select the number of sides of the cube, and then you just tilt the cube. The tilting detection was done by taking samples of the absolute acceleration vector for the last 100ms time-window and then calculating the deviation of the series. If the deviation is bigger than a certain value for a certain amount of time the dice is considered as “rolled”. When that happens the device will use the avr-libc supplied PRNG to select a number.