CharliePlexing on a ATTINY10

Introduction: CharliePlexing on a ATTINY10

This mini project combines a two things I had never done before. The first is CharliePlexing, the second is making (a kind of) die. In the 1980's and maybe even later, making electronic dice was pretty popular. I have seen them in the magazine Elektor and no doubt they appeared in other magazine such as Nuts and Volts too. Although I was a beginner with electronics at that time and those projects were clearly aimed at beginners I never made one. Now, after several decades I have :-)

The other thing, CharliePlexing I hadn't tried either, I knew it existed and I knew how it works but there never was a reason to use it. Now there was.

Code is now available on GitLab:

https://gitlab.com/WilkoL/charlieplexing-on-a-attiny10

Supplies

ATTINY10

Resistors 5 x 1kohm, 1 x 10kohm and 1 x 1Mohm (smd 0805)

Capacitor 100n (smd 0805)

2032 battery holder (plus battery)

Momentary button

PCB

Step 1: ATTINY10s Are Small

For another project I had bought a few ATTINY10 microcontrollers, and they really are tiny! A 9V block battery next to it looks like a towering skyscraper. But they are still big enough that I can hand-solder them. (When I buy parts I always buy more than I need, I do break parts. My "Wall-Of-Shame" contains too many parts where the "Magic-Smoke" has escaped from.)

So I had some spare ATTINY10 microcontrollers and the idea of making a dice. An electronic dice needs seven dots, three on either side and one in the middle. The microcontroller has six pins, but you can use just three of them, VCC and GND are needed to power it and /RESET can only be used if you can program it with a programmer that supplies 12V to this pin during the programming session. I do not have a programmer (yet) that can do that. So I just had those three pins.

Step 2: CharliePlexing to the Rescue

With CharliePlexing and three pins you can control just six leds, one short for a die! But with six leds you can show the numbers 1 to 6 by nummering them and lighting just one of them. That's how this die works. Or maybe I should call it a "Small Wheel-of-Fortune"?

But wait! We also need a button to start it, so we are still one pin short.

This is fixed by relying on the speed of a microcontroller, one pin is switched from output to input several times a second for a very short time, human eyes are too slow to notice that.

More shortages and randomness

The ATTINY10 isn't just tiny in size and number of pins, it also has a tiny flash memory (1 KByte) and even smaller amount of ram (32 Bytes) A program that uses a (pseudo) random generator would probably not fit in this microcontroller. So I chose to use the randomness of the time the button is pressed, as long as it is pressed the microcontroller rotates through the numbers 1 to 6, and thus the led that is switched on. When you release the button the rotation slows down for a few seconds and stops at a random number, just like a small "Wheel-of-Fortune".

Step 3: Power and LEDS

Electronic die / wheel-of-fortune need to be small and work on a battery, but not an AA or a 9V block battery, those are way too big. A CR2032 button battery has a nice format. That meant that the pcb had to be big enough for a CR2032 battery holder. The first design I made was 30 x 30 mm but I decided that it could be smaller and made one of a square inch (2.54 x 2.54 mm), hello Hackaday :-). Usually I do not design a pcb at all, but making something this small with perfboard and a microcontroller of this shape is too difficult, and the price of a pcb this size (if made in China) is so low, it costed me less than 7 euro to have 5 pcbs made and shipped.

The fact that it works on a CR2032 battery and that there is no power switch also means that the device needs to use as few electrons as possible and go into sleep mode when not used. As it is now it uses about 1 mA when in use and a few uA in sleep mode, so the battery will last long enough.

Using a 3V battery means that there is never more than those 3V for the leds, so blue and white leds will only work for a short time with a fresh battery (3.1V) A green and a red led need less voltage (I have measured between 1.8V and 2.4V). The green leds I have produce quite a lot of light with 1 mA, the red leds are a bit dimmer with that much current but still ok.

Step 4: The Code and How to Flash the ATTINY10

To conserve energy the clock of the microcontroller is reduced to 1 MHz, unneccesary peripherals disabled and all ports set to inputs when in sleep mode. Every round of the main loop ( while(1) ) all ports are set to inputs for some 2 milli seconds and the state of the button is checked, after that the current selected number determines ( switch(number) ) which ports are set to outputs and which one of those ports will be high or low.
When timeout has reached 0 (after a few seconds) all ports are set to inputs again, but with pullup resistors and Pin-Change-Interrupt is enabled. In Power-Down-Mode the microcontroller only reacts to an external signal. When you press the button one input will change from high (with the pullup resistor) to low and this will wake the microcontroller.

PROGRAMMING
The leds, together with the 1k resistors place too much load on the programmer to succesfully program the ATTINY10. So solder the leds after programming and the battery holder last. Oh, programming the ATTINY10 works only when it is powered with 5V, it will not work on 3.3V.

Attachments

Step 5: PCB

The pcb is designed in Kicad. I have selected 0805 size resistors and capacitors because that is the smallest size I can comfortably solder by hand. In Kicad you can choose to make all pads a bit bigger by selecting the "HandSolder" footprints. The battery holder is placed on the backside (of course), all other parts are on the topsize.
The way I solder the parts to the pcb is to put a little solder on one pad and then move the part to this pad and re-heat the solder when the part is in the right position, this works fine for the resistors, capacitors as well as the microcontroller. If I accidentally short some pins of the microcontroller it is fixed with some de-soldering braid.

I do not place the leds and the battery holder until I have programmed the microcontroller. The battery holder somewhat overlaps the programming pads (testpads) but that isn't too bad. But you cannot solder the leds when the holder is in place! While I had designed the pcb for 3mm leds, it turns out that 5mm leds also fit, but hey do they look huge!

Step 6: Soldering Step by Step

This is how I do it.

Step 7: Videos

Be the First to Share

    Recommendations

    • DIY Summer Camp Contest

      DIY Summer Camp Contest
    • Fandom Contest

      Fandom Contest
    • Pets Challenge

      Pets Challenge

    2 Comments

    0
    hhwill571025
    hhwill571025

    Question 5 months ago on Introduction

    Hi, a great project and very well described, thanks! And the programming environment used? (Really struggling to program the Attiny10, in a lowcost way, i might have to add.)

    0
    WilkoL
    WilkoL

    Answer 5 months ago

    Hello Hhwill,
    The IDE I use for all Atmel/Microchip microcontrollers is Atmel Studio 7. You can download it for free from Microchip. The programmer is an official AVR-ISP-MKII, I don't think you can still buy the official one and I don't know how well the clones from China will work.

    It should also work with an USBASP, see there for connections: http://www.technoblogy.com/show?1YQY

    I have made the USBASP work in Atmel Studio 7 once, but at the moment I don't remember how I did that. It was something with the "external-tools" and I later removed that because it interfered with the workings of the AVR_IPS-MKII. A google-search for "atmel studio usbasp" will probably do the trick.

    Remember that to program the ATTINY10 it needs to be powered with5V ! You can use it with lower voltages, but programming must be with 5V.

    Succes,
    Wilko