Featured on hackaday, gizmodo and hacked-gadgets

Acceleration-Sensitive Led Matrix

  • Fact: I am a new D&D player.
  • Problem: Having to roll many kinds of dice, which get lost and end up it other player's hands.
  • Solution: Build an n-sided dice.
  • Method: Take two 5×7 led displays, connect them to an ATmega168, toss in a Freescale's 3-axis MMA7260QT accelerometer and program some code.



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: Bottom view of the cube

Accelerometer soldering

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:

  • First I glued the chip to a tiny piece of perf-board with some hot-glue1)
  • I plated the chip pads with a little bit of solder
  • Next I put small pieces of wire-up through the holes and while holding them aligned to the pads I reheated the solder with a fine solder pencil
  • Finally I fixed the whole thing with a blob of hot glue

Certainly not a job for the faint of heart. You can see the result in this picture: Top view of the cube


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…

Dice Application

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.


  • Instead of using the ULN2008 I could have lit a single led each iteration instead of lighting up an entire row
  • Need to implement power saving mode, battery runs out too damn fast
  • Apps to implement: pedometer, red flashlight, marble and holes game…
  • Construct next version on a double-sided PCB:
    • Make it thinner
    • Use SMT ICs, and try to consume less power
    • Use better batteries

More Photos

1) in my opinion, the person who invented hot-glue should receive the Nobel prize


[...] Led Matrix Dice [...]
Digital Dice | News for Geek, 2009/05/21 08:09 (Pingback)
[...] built some digital dice [...]
[...] Itay's Showcase [...]
[...] Itay's Showcase [...]
[...] Itay's Showcase [...]
[...] Itay's Showcase [...]
[...] Itay's Showcase [...]
[...] Itay's Showcase [...]
[...] Led Matrix Dice [...]
[...] Itay's Showcase [...]
[...] Itay's Showcase [...]
[...] Itay's Showcase [...]
[...] Itay's Showcase [...]
[...] Itay's Showcase [...]
[...] Itay's Showcase [...]
[...] Itay's Showcase [...]
[...] Itay's Showcase [...]
[...] Led Matrix Dice [...]
[...] Itay's Showcase [...]
[...] Itay's Showcase [...]


, 2009/05/19 21:15
Very cool looking project.
, 2009/05/20 20:50
Nice, an intesting idea. AN IDEA: For a slightly smaller version, you could use 16 individual leds in a 4x4 grid (16 should be enough sides for most dice I would assume) and that would reduce the footprint. It could be made in 3D so as to allow the circuitry inside the shape, SMD chips would be ideal for that. You'd need two of those though (the dice), although you could have each of the two dice have one side for interconnection (ie, one side with a magnet and the other with metal) so that you could click them together. You could use two magnets, but if you use metal on one side instead you can add a reed switch on the die with the metal to sense if you are rolling one or two dice.
, 2009/05/21 14:22
J H one problem. D&D requires a 20 sided die to play, and other dice, but a 16 led matrix wont cut it
, 2009/05/21 17:03
what if you counted in binary? :P
, 2015/10/21 04:27
bSGeP1 <a href="http://tykkuiikyjpv.com/">tykkuiikyjpv</a>, [url=http://czvxgchooape.com/]czvxgchooape[/url], [link=http://dncxzmtkxlfj.com/]dncxzmtkxlfj[/link], http://ozsvtlczqoiq.com/
, 2015/10/23 15:05
OgJzI1 <a href="http://dxbtbgyxkgsb.com/">dxbtbgyxkgsb</a>, [url=http://zyidtpesrssr.com/]zyidtpesrssr[/url], [link=http://eghuscvfdczm.com/]eghuscvfdczm[/link], http://pskkmnorlpim.com/
, 2016/06/25 00:45
9KY81W <a href="http://fiajghmkvjis.com/">fiajghmkvjis</a>, [url=http://sniatggmawpr.com/]sniatggmawpr[/url], [link=http://wyjgrcrsnbbo.com/]wyjgrcrsnbbo[/link], http://ynaempynwbyg.com/
, 2016/10/14 17:16
vyG06G <a href="http://dhddgmgrgryz.com/">dhddgmgrgryz</a>, [url=http://jjcdbhczklfe.com/]jjcdbhczklfe[/url], [link=http://yvlnrhoqoydj.com/]yvlnrhoqoydj[/link], http://jdxgjjxpmhly.com/
, 2016/12/27 14:31
IPZOYs <a href="http://graesbeogdwh.com/">graesbeogdwh</a>, [url=http://gstdihgylxsr.com/]gstdihgylxsr[/url], [link=http://ckezgpzxknzq.com/]ckezgpzxknzq[/link], http://mwgrpqlfzmsr.com/
, 2017/02/06 04:02
5a6EIA <a href="http://olihaivhtleh.com/">olihaivhtleh</a>, [url=http://rdzxuibzgarc.com/]rdzxuibzgarc[/url], [link=http://lflwxrzhudji.com/]lflwxrzhudji[/link], http://kljevdotlsho.com/
Enter your comment:
215 -4 = ?
projects/ledmatrix.txt · Last modified: 2014/05/07 16:42 by itay · []
Recent changes RSS feed Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki Creative Commons License Get Firefox