Try making a double led dice with 14 leds driven only by 4 available pins of an Atmel Attiny13a. I did it, and it worked. See the result in this video.
14 leds can be driven by a technique called charlieplexing when not many microcontroller pins are available. This technique works from the fact that leds are diodes and that those diodes have a little voltage drop. In the network of leds, you can make one led turn on by applying a voltage smaller than twice the voltage drop of a led. In this way, only one led lights up. The other leds do not turn on because the voltage is not high enough.
To make all the leds light up you must cycle through all the leds very fast. Only one led can be turned on at a time. If you cycle through all leds very fast they all seem to be on at the same time to the human eye.
According to the schematic the pins PB0 to PB3 from the microcontroller are used to drive 8 leds, every 4 of those make one die (dice).
5 volt is needed to power the circuit. Any more and you will burn out the microcontroller. You can use your computers USB port to power the circuit. 3 pieces of 1,5V alkaline batteries also work. To prevent polarity reversal you can mount a reversed diode parallel to the supply voltage so that when you put the batteries in wrong you have a chance the board survives. I powered the circuit by a emergency USB phone charger, it seems to work great.
One of the four buttons in each corner on the bottom of the PCB can be used to trow the dice (inspired by Elmar on sk.net). Just press somewhere on the top of the PCB and they will signal the microcontroller on pin PB4 to start the trow.
When one of the buttons are pressed the microcontroller show random values on the leds. First at a fast pace to make throwing exciting and after a few seconds very slow ending in the value you threw, for example the value 4 and 2. The values shown are completely random, no cheating possible. This randomness is achieved by the simple fact that the moment of pressing one of the buttons (by a human) is unknown and thus random. When the buttons are not pressed the microcontroller is cycling through 1 to 36 (6×6) very fast. Pressing one of the buttons the value is frozen and that is the value you get.
You can make this double led dice yourself by programming the provides hex file in an Attiny13a microcontroller.
Program the high fuse with 0xFD and the low fuse with 0x72.
You do not have to use the SMD version of the Attiny13a. A through-hole version also works. You can even use giant 10mm leds instead of tiny 0805 smd leds.
Want to try writing software yourself? Use the following tables to see how the leds are hooked up to the microcontroller:
D2A and D2B turn on at the same time, just as D3A and D3B, and DnA and DnB… etc.
For example, to show the value “1”, D1 must be turned on. To show the value 2, turn on D2. 3: D1 and D2. 4: D2 and D3. 5: D1, D2 and D3. 6: D2, D3 and D4.
Did you like this post? Please give it a thumbs up by sharing it on your social network. Thanks!