Dice ATTINY85 Charlieplexing
Intro: 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.
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.
14 Comments
Vojťák 8 years ago
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 8 years ago
Darduino_dice.ino:30:40: fatal error: Entropy.h: No such file or directory
compilation terminated.
Fout bij compileren.
Darduino 8 years ago
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 8 years ago
https://sites.google.com/site/astudyofentropy/file...
entropy lib adress
Darduino 8 years ago
and restart ARduino iDE after
BenK6 8 years ago
i am trying to make it but programming is the problem
the code is not working wat am i doing rong please help
Darduino 8 years ago
amberrayh 8 years ago
Very cool! Thanks for sharing. Do you have a video of the dice in use?
Darduino 8 years ago
yes i do. it's online since this morning.
amberrayh 8 years ago
I love it! Thanks for the video.
Darduino 8 years ago
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 8 years ago
cool
rlitwiński 8 years ago
hi, this is my project
Darduino 8 years ago
it's a cool project