(right dice was the first one)

Tutorial for a DIY dice with Attiny85, Tilt sensor, Charlieplexing, Crystal resin.

it's easy way to build your own little electronic dice for good price.

French version on my blog

Inventory list

• Attiny 85 with socket
• Tilt sensor
• Led
• 39 ohms resistors
• Crystal resin
• gloss for crystal resine
• ice cube tray 3x3x3 cm

## Step 1: Wiring the Dice

Charlieplexing :

The rule usable to define the number of leds that you can drive with a number of pins :

(nbpin x nbpin) - nbpin

With 4 pins it's possible to drive 12 leds, with 3 pins only 6 leds. We need to drive 7 leds ==> we need to use 4 pins.

Use the Attiny socket to simplify the wiring.

Attiny Pin 1 - Resistor - Line 1 (blue)

Attiny Pin 2 - Resistor - Line 2 (green)

Attiny Pin 3 - Resistor - Line 3 (red)

Attiny Pin 4 - Resistor - Line 4 (black)

in a second time wire the button battery.

Attiny gnd - button battery (-)

Attiny Pin + - tilt sensor - button battery (+)

I use the tilt sensor as an interruptor.

## Step 2: Programming the Dice

Load the Attiny 85 sketch (i use a arduino as a ISP).

upgrade speed clock at 8 MHz.

Understand the sketch

2 libraries :

• Entropy : used for random and replace the wrong standard random function.
• EEPROM : used to write in Attiny and perform the randomseed number after each switch off.

2 two dimensions arrays :

• tabled [7][4] : used to map led and pins
• dede [8][7] : used to group led for representing the dice number.

functions

• afficheled(int numled,int temps) : Display one led (numled) for a delimited time (temps)
• affichede(int n ,int temps) : Display the dice number (n) for a delimited time (temps)
• Lancedes() : dice generation. this function show several number before the final one.

## Step 3: Build the Dice

You need to protect the button battery place against the resin, i use playdoh.
When you mix the resin with hardener, wait until the air bubbles disappear.

One complete week for drying the dice.

<p>Yes, charlieplexing is useful when you need driving many LEDs independently. But have you ever seen the dots on a dice? The six dots go always in pairs, so 4 pins are enough even without charlieplexing ;-) But good proof of principle.</p>
<p>Darduino_dice.ino:30:40: fatal error: Entropy.h: No such file or directory<br>compilation terminated.<br>Fout bij compileren.</p>
<p>and restart ARduino iDE after</p>
<p>i am trying to make it but programming is the problem</p><p>the code is not working wat am i doing rong please help</p>
Can you describe the problem ?
<p>Very cool! Thanks for sharing. Do you have a video of the dice in use?</p>
<p>yes i do. it's online since this morning.</p>
<p>I love it! Thanks for the video.</p>
<p>I have one with the wrong random dice, but now i waiting for dry a last dice with entropy. And after, i will publish the new video.</p>
<p>cool</p>
<p>hi, this is my project </p>
<p>it's a cool project</p>