Introduction: Dice ATTINY85 Charlieplexing

(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

Picture of 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

Picture of Programming the Dice

Compile and Upload the sketch

If it's your first time with Attiny 85, follow this link : http://highlowtech.org/?p=1695

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.

Download the full sketch !

Step 3: Build the Dice

Picture of 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.

Comments

Vojťák (author)2015-08-05

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.

BenK6 (author)2015-06-11

Darduino_dice.ino:30:40: fatal error: Entropy.h: No such file or directory
compilation terminated.
Fout bij compileren.

Darduino (author)BenK62015-06-12

you need to add entropy library to your ADUINO IDE before compilation.

use the menu function "add library" after download the zip file on the right web server. See the tuto : http://www.arduino.cc/en/Guide/Libraries

Darduino (author)Darduino2015-06-12

and restart ARduino iDE after

BenK6 (author)2015-05-30

i am trying to make it but programming is the problem

the code is not working wat am i doing rong please help

Darduino (author)BenK62015-05-31

Can you describe the problem ?

amberrayh (author)2015-05-22

Very cool! Thanks for sharing. Do you have a video of the dice in use?

Darduino (author)amberrayh2015-05-29

yes i do. it's online since this morning.

amberrayh (author)Darduino2015-05-29

I love it! Thanks for the video.

Darduino (author)amberrayh2015-05-23

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.

diy_bloke (author)2015-05-23

cool

rlitwiński (author)2015-05-23

hi, this is my project

Darduino (author)rlitwiński2015-05-23

it's a cool project

About This Instructable

5,988views

102favorites

License:

More by Darduino:Dice ATTINY85 Charlieplexing
Add instructable to: