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.
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.
http://books.google.co.uk/books?id=v9qwbBalahoC&pg=PA94&lpg=PA94&dq=the+pic+microcontroller+your+personal+introduction+dice&source=bl&ots=5JzDlRUWgf&sig=kpljrI0FsgBGJHnCvbjt1A3jfSI&hl=en&ei=T1ZzTu_EDsrHsga9oaHOCw&sa=X&oi=book_result&ct=result&resnum=2&ved=0CCUQ6AEwAQ#v=onepage&q&f=false
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.
“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.
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.
But minimalism is fun! Except a smaller uC, you could probably do away with the resistors as well if you drive the uC at a low voltage and some pwm usage
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.
“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.
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.
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.
Edit: Last one only goes on for number 6.
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.
Forget charlieplexing, you can reduce this to 8 LED pins by combining LEDs that will always be lit together onto the same pin.
Regular multi-plexing could bring the pin count down to 9.
7 LED lines with a common cathode (or anode) being directed to an enable pin for d1 or d2.
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
and tie all the led’s to ground.
D’OH! I missed @revs post above… sorry *blush*
no more dice do something more challangeing like tv pong or a wav player if not change it from attiny hacks to dice hacks
One of my favorite die circuits is here: http://www.kpsec.freeuk.com/projects/dice.htm
It doesn’t charlieplex, it uses the principle that other than the center pip, all the pips on a die appear in pairs. Gang the pairs and ta-da — dice in 4 lines of output (8 for 2d6).
Or 5 is you put the LED’s in opposite directions with NPN and PNP transistors to switch them.