This is a shitty add-on with one RGB LED controlled by twelve switches. The top row controls the red brightness, the middle row controls the green brightness, the bottom row the blue brightness. Each row of switches is like a 4-bit binary number, giving 16 brightness options for each color channel.
Should I have used knobs instead of switches? Maybe, but then it's not a shitty add-on, is it?
Each color channel is controlled by its own ATtiny10, reading an analog voltage and PWMing the LED accordingly. The ATtiny10s are programmed using [Simon Merrett]'s SOICbite footprint, which I *love*.
Should I have used a 555 instead of a microcontroller? Perhaps. But isn't this a better solution for a shitty add-on?
Now that I know the ATtiny10s work, it's time to publish the project! I am still waiting for some common-cathode RGB LEDs to arrive; until then I can just test one channel at a time.
The most recent KiCad PCB is actually a little different than the physical PCBs in the photos. I originally routed power to sides of the LED, but that's easy to fix with a little hidden rework on the underside of the PCB. The lovely Oshpark After Dark front side is unharmed!
Really? Microcontroller? Three of them!? for this task?
It would be so much easier to give each switch its (roughly) binary weighted resistor, let's use 220, 470, 1k and 2k2 and these combined resistors control the current to the LED, switched off or in parallel.
Alright, let's pretend I have perfect 250, 500, 1k, and 2k ohm resistors in series, just to make things cleaner. Now let's say each switch shorts out a resistor when it's toggled ON. Let's also say there's a 2k ohm resistor in series that can't be shorted, so we never let out the magic smoke.
If I toggle all the buttons OFF, the LED is still on! Dim, but still on! That's no good, I want my LED to be OFF when all the switches are OFF.
Okay, fine, let's try putting all the resistors in parallel, and wire it up so each switch breaks a resistor. Now, if all four switches are OFF, no current can flow and the LED is off! HOWEVER: the equivalent resistance of the resistors in parallel is not linear. There's mathematically no way to get evenly-spaced equivalent resistances. We can't even get close (feel free to try! it's kind of relaxing to compute equivalent resistances, if you ask me).
So, resistors in series fail to turn the LED all the way off, and resistors in parallel fail to provide evenly-spaced brightness options. I don't know about you, but $0.75 worth of microcontrollers sounds like a pretty good solution to me :)
The equivalent resistance of the resistors in parallel are not what you need. LEDs are current controlled. Assuming a constant voltage on the resistors, each one adds his share of current into the LED. Even with the E12 resistors you will probably not see the less than optimal linearity. If you want you can get 2k, 1k, 499 ohm and probably something like 250 ohms, or you use 2*499 in parallel. Or 2* 1k, 1k, 2* 1k in parallel and 150 + 100 ohms. As resistors cost nearly nothing (less then 0,1 ct in bulk for 1% chip resistors), you could even use identical resistors in series and parallel configuration to make the binary weighted resistors.
A µC is not only it's cost in parts, but it also needs some program to do anything. This is extra effort and has to bring additional use. Which it doesn't in this case.
BtW: If you want to short out the series connected resistors, you would not want a 2k resistor that can not be shorted, but some low value for max. brightness, e.g. 250 Ohms (220, 270) that gives max. brightness.
(sorry to keep replying, I think this is the last one!)
Okay, actually, there is a saving grace to the microcontroller approach, heh. I'm not *only* driving the LED on the side of the badge; I'm also sending 3.3V PWM power to the three ports at the top of the badge. This enables me to control the brightness of three auxiliary SAOs. I genuinely can't remember why I wanted to design it this way instead of simply driving one LED; this SAO has been on my workbench for well over a year.
The original draft included a knob and a bistable 555 to turn the whole thing on/off, too ;) I sorta regret taking it out, but it would have made this big SAO even bigger. Glad you appreciate the project!
Really? Microcontroller? Three of them!? for this task?
It would be so much easier to give each switch its (roughly) binary weighted resistor, let's use 220, 470, 1k and 2k2 and these combined resistors control the current to the LED, switched off or in parallel.