Dice ATTINY85 Charlieplexing




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

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

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.


  • 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

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.

Be the First to Share


    • Puzzles Speed Challenge

      Puzzles Speed Challenge
    • "Can't Touch This" Family Contest

      "Can't Touch This" Family Contest
    • CNC Contest 2020

      CNC Contest 2020

    14 Discussions


    5 years ago on Introduction

    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.


    5 years ago on Introduction

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


    5 years ago on Introduction

    i am trying to make it but programming is the problem

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


    Reply 5 years ago

    Can you describe the problem ?


    5 years ago on Introduction

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


    Reply 5 years ago on Introduction

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


    Reply 5 years ago on Introduction

    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.