Instructables

ATtiny85/45/25 LED dice (Super simple and CHEAP!)

Featured
If you have looked at my 5 LED ATtiny85 POV display, we programmed the ATtiny with the Arduino. (If you haven't seen it, click here) We will be doing the same thing for this LED Dice project.

The total parts cost for this project is about $5-$10. (Not including the Arduino board and the tools.)

It is super simple to make, so don't worry if you don't have a lot of programming/ electronics experience.

This is a contest entry for the LED Contest with Elemental LED, so don't forget to vote for me! ;)


 
Remove these adsRemove these ads by Signing Up

Step 1: Parts list

Here's all the stuff you need. You can get it all for 5-10 bucks if you buy from Mouser/Digi-Key.

Parts:
1x ATtiny85/45/25 (8 pin DIP)
1x 8 pin DIP socket
1x Tactile pushbutton switch
1x 10K Ohm resistor
7x LEDs (I used clear, high-brightness red. We will be powering this with a 3 volt battery pack, so make sure you choose something that can handle that much power)
1x 2 AA/AAA battery pack (could also be a 3 volt CR2032 coin cell battery, just make sure whatever pack you choose that it's 3 volts)
Some perfboard
Batteries that go with your battery pack
Some wire

Tools:
Arduino board (for programming the ATtiny)
USB A-B cable (for plugging in the Arduino)
Soldering iron
Thin solder
Helping hands (optional, but very helpful for soldering)
Something to cut down the perfboard to size (I used my Dremel)
waterlubber2 years ago
Yay, I finished my utterly complex one!
HNI_0078.JPGHNI_0076.JPGHNI_0074.JPGHNI_0073.JPGHNI_0075.JPGHNI_0072.JPG
xBacon (author)  waterlubber2 years ago
Cool! is there an ATtiny in there somewhere or are you using the Arduino only?
mboroff7 months ago

So I thought it would be neat to build two of these on one board. After all most games use two dice. Anyway I have one double DPDT switch turn the power on both circuits at the same time. Well it turns out that both dice seem to almost always show the same value when you hit the switch to display a number. Since there is no clock or anything unique to make one randomize different from the other. So other than modifying one die with a variation on the random number generation, anybody got any ideas would be appreciated.

dice.JPG
diymaster1239 months ago
Works great!!!
attiny.JPG
ok so i mad emy own version of this before i even saw this one and i seems to be the same pretty much, I used an ATtiny 85. if tried 3 different sketches and none of them work, is one only flashes a 3. Please help!?
I had to change over some of the pins in your code, This is what I had:
int pinLeds1 = 4;
int pinLeds2 = 1;
int pinLeds3 = 0;
int pinLed4 = 3;
int buttonPin = 2;
Works good.
DSC_0392.JPG
xBacon (author)  UnusualTravis2 years ago
Thats a pic of the one you made? Nice! I always like to run things on a smaller battery so its more compact, so i like how you did that.
This little guy works great but I revisited this last night, I found that the battery life wasn't as good as it could be due to the chip always ON even when not in use, now my code puts the attiny85 into a "sleep" mode and wakes up when you press the button, the button has to be wired differently, the Switch must pull the attiny85 LOW instead. Batteries can last a much longer now. but now I need a new PCB :)
Hi, I also made an LED dice out of an Attiny25, you may wanna look at my code, as mine makes the chip go to sleep after it finishes with the numbers and so the batery can last up to 80 YEARS!
you may wanna add some sleep functions to your code, I managed to get the power consumption to less than 0.1 microAmps!
No way! The battery would expire by then...
How does sleep work? I same with him
VVVVVV
yeah, thst's true, the actual self discharge of the battery is more tha the power needed by the chip itself, of course, what takes most of the battery's energy is the LEDs when they are ON.
xBacon (author)  Emiliano Valencia2 years ago
Oh yeah, emihackr97, when i tried your code it messed up my ATtiny. It wouldn't let me upload any sketches to it but when it did it just didn't display any numbers when i pressed the button...
I don't know what could have happened, maybe you can just adjust the pins in my code to fit your dice.
BTW, I didn't use any resistors for the button.
xBacon (author)  Emiliano Valencia2 years ago
Oh cool! I had a look at your code, but I dont quite understand how the whole sleep thing works. Maybe you could PM me and tell me how that works?
Yeah, it's really simple, once it is done diplaying the numbers, the chip goes to sleep, reducing power consumption to only 0.1 micro Amps, that's 0.3 microWatts!
then, the button is just an interrupt that wakes up the chip so it displays a new number.
waterlubber2 years ago
@xbacon: No ATtiny in this one...still waiting for my order to arrive. For some weird reason, there is no reply button. (On that message. Weird...
waterlubber2 years ago
This is an AWESOME instructable. Here are a couple of questions: -Can you give me some info on the ATtiny? I have an ATmegaXXX(don't remember three digit code, too lazy to go get the arduino) and I want to know about this ATtiny. Seems cool. -In you code with the if statements, wouldn't be easier to use a switch case http://arduino.cc/en/Reference/SwitchCase
xBacon (author)  waterlubber2 years ago
Thanks for the compliment!

Here is some information about the ATtiny's.

The ATtiny85 that I used here is a simple 8 pin AVR chip made by Atmel. The '85 version has 8KB built-in flash storage for storing your code. In comparison with the Arduino, the Uno version (which is the newest one) has an ATmega328 on it, which has 32KB of flash program storage instead of the 8KB that the ATtimy85 has.

The ATtiny85 has 4 Analog input pins for reading data from analog devices such as potentiometers, force sensors and LDRs (light dependent resistors). The Arduino has 6 of them. The Analog pins on both the Arduino and the ATtiny85 can be used as Digital outputs also.

The ATtiny has 2 dedicated Digital output pins, which are both PWM. The Arduino has 11, 6 of which are PWM.

The 8 pin ATtiny's come in 4 kinds. The '85 has 8KB of program space, the '45 has 4KB of program space, the '25 has 2KB of program space, and the '13 has 1KB of program space. I always get the 85's because they are less than a dollar each on Digi-key and Mouser, and they usually have enough space to store some pretty complex programs.

I could go on forever, but I'm going to stop here so I don't start to bore you. ;)

Also, about the SwitchCase statements, I don't think the ATtiny's support it. They only support simple things like "if" and "delay" and "digitalWrite" statements. Correct me if I'm wrong.
Thanks. Just noticed something about those numbers:
328 = 32 KB
85 = 8 KB
The last digit is probably a model or something.
Those attinys are AWESOME!!! I believe that "simple" code is C, not C++ (arduino). And its pretty hard to bore me. Can you use the arduino volt reg, usb-serial bus, and stuff like that to run the tiny? By, like, connecting all the pins on the tiny to the arduino? Thanks, and that dice thing with the 4 pins is a GREAT idea!
xBacon (author)  waterlubber2 years ago
You're right about the numbers. The ATmega168 that was used in the Diecimila and the old Duemilanove's had 16KB or space, hence the 168.

Yes you can use the Arduino as a power supply for the ATtiny, just connect Vcc to +5v on the Arduino and GND to ground on the Arduino. You can plug the Arduino into a USB plug on your computer or from a wall to USB charger adapter, or you could plug a 9 volt battery into the DC jack and use it that way.

I recommend using a 3v power source for smaller projects though. Here I use a 2x AA battery pack to power it. The ATtiny85V's can take anywhere from 1.8 to 5.5 volts. The regular ATtiny85's without the V can take 2.7-5.5 volts.

Thanks for the compliment (again)! haha
How did you go about multiplexing?
xBacon (author)  VirtualBoxer2 years ago
It's not really multiplexed, the LEDs are just wired in pairs. if you look at step 2, it explains how this works.
cool!
xBacon (author)  amandaghassaei2 years ago
Thank you!