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.

Thanks [Roeland] for sending this in.

20 thoughts on “ATtiny Hacks: Roll 2d6 With An ATtiny

  1. The PIC microcontroller: Your personal Introduction by John Morton. Does this using a PIC12F508 which only provides 6 i/o pins (well 5 i/o and 1 input only).

    Here is an extract from the project.

  2. 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.

    1. “Does it actually save on board real estate or costs?” Yes. Without it you would probably need a bigger microprocessor or other support chips to support extra pins.

      “Does it make the programming more complicated?” Yes it does, but if you have the space and CPU cycles available and don’t want to pay for hardware, that’s a very valid trade off.

      1. 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.

  3. 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.

    1. “I really don’t see how this is charlieplexed when each LED’s have their own I/O pins?”

      It’s not charlieplexed, the article was saying that if they had used charlieplexing, then it could have been done with a smaller chip.

      They could have multiplexed and saved half of the pins, but it doesn’t matter because this does what the builder wants it to do… and that is all that matters.

    2. RTFA…

      It specifically mentions charlieplexing is NOT used. but that it could have been to have a uC with less pins, and to use less board space…

      Since there is a significant financial benefit to using a smaller chip I’m not sure I agree that Charlieplexing would be a good choice here anyway.

      The cost difference between the two devices is measured in pence, the extra board material is also measured in pence…

      So working an extra hour to save a couple of pounds, or a few dollars would mean working for less than minimum wage. -or spending a large effort for very little return.

  4. 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.

      1. 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

  5. “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.

  6. 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


    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

    and tie all the led’s to ground.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.