Summary
Christmas is coming soon. Take one of these simple battery operated led strings. Mine was from IKEA. You get a nice red battery case, a power switch, a resistor, and a string of 10 red leds with cabling. No way you could source alle these components on your own for less or quicker - unless you are planning to build a 3 digit number of these and break it down.
Anyway, I didn't like the simple on/off switch. Sure, I can switch it on in the evening, but I can't be bothered to remind myself to switch it off before going to bed. A timer was needed.
Nowadays, everything is powered by microcontrollers, why not a simple battery led string as well...
The timer circuit is an ATtiny45 microcontroller, which is cheap, doesn't need many external components and was what I had at hand. See the last picture for the schematic.
The timer circuit does not have an on/off switch. The reset button starts the operation (timer function). After a programmable amount of time (see config.h - anything from seconds to multiple hours, mine is programmed for 6 hours), the led string is switched off and the controller goes to power-down sleep mode (power consumption approx. 0.4uA at 3V). No need for an on/off switch. Pressing the reset button again starts anew. Pressing the second button while the string is active switches to power-down mode immediately. The firmware is in the files.
Because the circuit did not fit into the battery housing, I printed a simple case which houses the strip board with the controller and the two buttons. The size can be adjusted (see params in scad file).
One more thing: You can power this led string easily with used AA batteries. I usually collect used batteries over the year (from toys, alarm clock etc.) - and use them again here. A good re-use for used batteries before giving them into the recycling bin.
The last picture shows a version with 20 leds and 3 AA batteries, where the circuit fits into the battery case.
Instructions
Open the led string battery case and replace the built-in resistor with a wire bridge.
Build the circuit on strip-board. It might be advisable to either flash the firmware before connecting the led string with resistor on PB0 (see schematic) or to make sure you can temporarily remove it for flashing the firmware (see detail picture of perfboard where the resistor for the led string is not soldered in but just attached to a socket). The reason for that is that PB0 is also used as MOSI pin for the ISP interface and the programmer might have problems driving the Port appropriately, would the resistor be connected while flashing)
one more note: I used an 68 ohms resistor for the string, not 100 ohms as in the schematic (the schematic is for the 3x AA version).
Build the fimware (make program if you have the complete avr-gcc toolchain and avrdude installed) and flash it e.g. with avrdude and usbtiny programmer.
Print the case and attach the buttons and perfboard with hot glue. Close the case with two M3 screws, washers and nuts.
标签
模型来源
