A Custom Duty-cycle Controller
It's been a busy couple of months, so this is a very simple build. It's essentially just a small, cheap, high-frequency duty-cycle controller. I use these for a variety of things, but mostly for various forms of dimmable lighting.
Of course, there's a classic 555 timer circuit for this. However, there are a few things I don't like about this approach:
- The 555 timer is not much cheaper than a microcontroller (~0.29 cents vs. ~0.36 cents for an attiny10)
- It requires more external components than a microcontroller, driving the cost higher
- It takes more board space than a microcontroller
- It's slower than a microcontroller, so without a bit of careful design, you can get some flicker in your lights
- It generally uses more power than a microcontroller
Enter the Attiny10
One advantage of course, is that a 555 timer is a standard part that is always available, and it can tolerate higher voltages.
However, for making dimmable lights, that doesn't matter much to me, and I really have a lot of attiny10 microcontrollers. I buy 100 at a time -- there are few products in the world that offer me so many hours of entertainment for that price. They consume just a couple of microamps, and are definitely fast enough for our application.
It's become my standard microcontroller.
A Lamp for when you have a Migraine
Anyway, our first application for this design is quite simple: a lamp that's less painful to use when you have a migraine. A major symptom of migraines (besides the terrible pain) is photophobia -- the very idea of light hurts. However, it's not really practical to just lie in complete darkness for an indefinite period. Eventually you'll need to drink fluids, eat something, navigate around a room, etc. Turning the lights on is a painful proposition.
So I had the idea to make a dimmable, diffused red light with big tactile controls. On applying 5V power (a big in-line switch), it lights up very dimly. Then turning a large dial increases the brightness as needed. The high duty-cycle frequency ensures that it never flickers visibly, and the red light seems to be easier to endure than other colors. It's not life-changing, but it does make waiting for a migraine to end a bit more bearable.
An alternate use is as background lighting when watching a film in a dark room. I use it a lot this way, it's sort of nice.

Half-Price PCBs
The circuit is designed as a single-sided board to make it cheaper. Each board splits in half so that you get twice as many units -- PCBs cost me about VND 200.000 for 5 (190.000 for a single-sided PCB), this way I get 10 units instead of just 5. As long as you don't go overboard with this technique, the manufacturer generally won't mind.

Adding a Case
I built it into a case I recycled from (appropriately) a bunch of 555-timer based duty-cycle controllers for motors. I had received a lot of these as scrap a few years back, and have been slowly recycling them into projects -- the heatsinks, potentiometers, cases, and capacitors were worth salvaging.
There's also an LM7809 and a power MOSFET -- but I don't build 9V systems much and the Vgs(th) of the power MOSFET is too high to be generally useful to me. It's not a particularly pretty build, but I've had very little free time these past months. Anyway, it does its job.
The lamp looks fine. It's utilitarian rather than pretty, so I didn't bother with a photo for this one.