A PIC Powered Pair Of Electronic Dice

[Timothy] is honing his microcontroller skills with this electronic dice project. In addition to giving him an opportunity to work on some code, the use of an 8-pin chip provides a design challenge for driving the twelve pips and providing a user input.

The project started off with some $4 strings of LED Christmas lights. He promptly disassembled the strands, each yielding 100 LEDs. The microcontroller he chose to work with is a PIC 12F629. It’s DIP8 package provides six I/O pins to work with. When examined closely you will find that the pips on a die are always present in pairs with the exception of the center pip. This means that only four pins are needed to drive one die. You can see a pair of transistors above; one is a PNP, the other an NPN. These are both driven from the same uC line, which toggles between the pair of die. This accounts for 5 of the available pins, with the sixth monitoring the push button.

22 thoughts on “A PIC Powered Pair Of Electronic Dice

  1. I like projects that use 8-pin chips. They always look so neat.

    Few suggestions:
    1. RA3 has internal pullup option and does not need an external pullup
    2. 7 + 7 = 14 LEDs, drivable via charliplexing using 5 pins. This configuration would avoid the need for external transistors and resistors (max duty cucle will be small, and current is limited by PIC’s IO pins)

      1. Not necessarily true, when charlie-plexing you can push higher currents through the leds to help make up for the difference in time spent off.

        Almost all LED’s have an extra rating called pulse-current which usually specifies the duty cycle as well.

      2. Besides pushing higher currents, the trade offs includes excluding the resistors (reducing parts count), increased wiring complexity and increased programming complexity.

        It’s the last two that can cause problems. If I feel like being slick and use Charlieplexing in a project, I have to keep careful track of any changes in the wiring and write copious notes in my routines because six months later I’ll come back and go, “WTF was I thinking?”

        To figure it out in the shortest amount of time usually involves copious amounts of caffeine, alcohol, or mind altering drugs or some combination of the three.

        My body can only take so much abuse.

      3. @SavannahLion:

        I know what you mean about your body being abused. Mine’s been through the wringer – I’m surprised I can still do what I do.

        As far as “WTH” feeling when going through old projects – I have had that before, even to the point of vocally criticizing code (and the programmer) to my colleagues, only to stumble across _my_ initials in the code. Oy!

        I am currently reworking one of my first projects that I worked on after my strokes, a remote-controlled AC outlet. Besides being really ugly – my soldering skills weren’t quite back to snuff yet – it wasn’t put together well. I plan to use it for my Christmas lights on the office patio, just point the remote through the window and turn the lights on and off.

        BTW: Thanks everyone for the comments, and thanks to Hack-A-Day for posting my project!

    1. RA3 does not have a weak pull-up. Per the spec:

      3.2.1 Each of the GPIO pins, except GP3, has a individually configurable weak internal pull-up.

      So the 10k pull-up I included in the design is required. I tried it without the 10K pull-up, with the /GPPU bit in the CONFIG register set to both ‘1’ and ‘0’, and – it doesn’t work. Either it sees the button as always pressed, or there are spurious glitches on the line. And the ‘roll dice’ button doesn’t work.

      As to the charlie-plexing – I could put RA2 on the anodes of one set of LEDs and the cathodes of the other set and then use that to select the die face. I’ll try that out on my next board. I’m making Christmas presents – heh – so there will be quite a few made.

      Most of the resistors are on this board because I have to connect the PICKIT2 dongle to it for in-situ programming. When I get to the ‘production’ versions – IE: the ones I will use for gifts – the PICs will be pre-programmed and I won’t need the ISP header, socket and most of the resistors. If the charlie-plexing works, that will _really_ reduce the part count.

      Thanks for the ideas!

    1. I used the PIC 12F629 because it was what I had, other than a PIC 12F1840 which really would have been overkill. I like the 12F629 as it is versatile for a lot of different projects. Plus a little faster (8mhz), which allows me to do bit-banging I2C at around 80Khz.

      I haven’t seen the other die projects out there – I previously did a single die version, which display two die values on one die by ‘flashing’ between the values. I guess the evolution of projects that use an I/O limited micro seem to follow similar paths.

      I used to be a hw/sw engineer for various startups and larger companies – but have since been sidelined by 4 brain stem strokes. I can’t do fine soldering anymore, so I stick with through-hole components and DIP ICs instead of surface mount. I mostly just do these type of projects to keep my skills honed and not go stir-crazy in my forced retirement.

      The most important thing to me is I have fun doing these projects – some small (like this) and some big. Can’t work anymore, so I might as well hack!

Leave a Reply to timothyscarlsonCancel 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.