ATtiny hacks: Roll 2d6 with an ATtiny

A pair of 6-sided electric dice (original in Dutch, here’s the Google Translate link) was sent in on the tip line for our ATtiny hacks theme. We really appreciate the simplicity of the circuit; it really shows how the complexity of discrete components can be cut down with a simple microcontroller.

The circuit is very simple – An ATtiny26 serves as the core of the project. Fourteen LEDs are connected to fourteen pins on the micro. The tiny26 might be a bit overkill. With Charlieplexing, we suspect this build could have been completed with an 8-pin micro like an ATtiny25. The code for the build (written in BASIC with BASCOM-AVR), board files and schematics have all been posted.

We’ve seen a few electronic dice builds before. this build uses an ATmega328 in a hugely overwrought circuit. Compared to what can be done with a 555, the ATtiny26 build provides a very nice middle ground.

I don’t understand this blog’s fascination with charlie plexing. Yes, it uses less pins. Does it actually save on board real estate or costs? No. Does it make the programming more complicated? Yes.

Overall, I don’t see the benefit and that’s especially true with this project. It would be one thing if there truly weren’t enough IO pins available, but that’s not the case here. I’m not trying to be overly critical or anything like that – I just think the build is fine the way it is.

I think what signal7 is saying is something I’ve noticed before as well. I see a lot of projects with a very powerful ucon with > 24 GPIO pretending to be an under-powered low pin ucon. I can understand the reasoning for optimization, but efficiency means also fully utilizing the resources at your disposal.

I really don’t see how this is charlieplexed when each LED’s have their own I/O pins? like one die is controlled by PortD already and you can set those in binary like 0b001101, and the other is using PortC.. so there’s no charlieplexing there, unless he is turning on the LED’s one by one.

No need for charlieplexing. You can show 1 to 6 with only 4 lines to the leds. One line to the middle led (1, 3, 5), one to the led on top left plus the led on lower right (2, 3, 4, 5, 6), one to the ones on top right and lower left (4, 5, 6) and one to the ones on middle left and middle right (5, 6). So basically you’ll have 3 pairs that go on/off and a single one.

i take everything back.
with reducing it to 4 led-groups as rev lists them, and charlieplexing you can fit two dice into 4 lines. which leaves 2 direct lines for whatever button functions you want to have. so, it does fit on an 8 pin micro

“with charlieplexing, we suspect this build could have been completed with an 8-pin micro”

and how would you get a couple of buttons plus a 4×4 matrix down to 8 pin without using additional logic chips?
i guess you could take the two empty spots on the 4×4 to check for button presses between led updates, have the buttons interfere with your leds, and the led refresh with your button debounce and also give up on ever using interrupts. but even then you still have 8 pins in use, an 8 pin micro has 6 io.

You could knock the number of pins down to 4 for the led’s and 2 for the commons. If you think about the sides of a die, there are three sets of dots that are always on in pairs. You could simplify the pin count to:

Pins ( multiplexed ):
1: center dot
2: top left and bottom right
3: top right and bottom left
4: middle right and middle left
5: common for first die
6: common for the second

-or-

Pins ( without multiplexing ):
( first die )
1: center dot
2: top left and bottom right
3: top right and bottom left
4: middle right and middle left
( second die )
5: center dot
6: top left and bottom right
7: top right and bottom left
8: middle right and middle left