It’s Advent season. And what do you do to let your geek shine? An LED Advent wreath of course.
The idea came to me after seeing Sprite’s minimalistic version of the Hackaday’s Flickering LED circuit. It’s a simple circuit that flickers LEDs and detects darkness. I thought that this could make a great little Advent wreath. My version should have 4 LEDs and should be support first, second, third and fourth Advent.
Parts and Schematic
The parts list is rather short:
- ATtiny13V, 8-bit microcontroller, 1k flash RAM, 64 bytes SRAM
- 4 * 3mm LEDs, yellow or orange, forward voltage ~ 2.0 V
- CR2032 coin cell, 3 V, 230 mAh
There are no current limiting resistors in this circuit. Normally operating LEDs without them is not advisable because the LEDs will get damaged. But under certain conditions the resistors can be left out. For more on this topic, see Sprite’s computation or mine here.
How does it work
The nice thing about this circuit is, that it needs no special components to detect darkness. It uses an LED for that. An LED is also a photodiode that can detect light of the same wavelength it emits. See here for more details. Sprite used an available ADC of the ATtiny13 instead of the “Reverse Bias” method.
The software is heavily based on Sprite’s version. Things I’ve changed:
- Added support for four LEDs.
- Removed calibration, replaced with hard wired values.
- Added a bit sampling to the light measurements, because the values were a bit erratic.
- Added a mode for first, second, third and fourth Advent, stored in EEPROM. Gets incremented at every reset.
- Modified the watchdog code a bit to keep it generating interrupts instead of resets.
After power up, the watchdog gets enabled to generate an interrupt every two seconds. Then the current mode (0-3) is read from EEPROM, incremented and stored back. Then the endless loop is entered, where random values are used to flicker the LEDs. The ISR checks the ambient lighting and if it is higher than a certain level, sets a sleep flag. This flag is monitored in the main loop. If set it sends the controller in to power down mode to save battery power. The next interrupt will wake up the main loop.
This circuit is soldered in “free form”, so no PCBs. It takes some time to get it done but it’s worth it.
All cathodes of the LEDs are connected to form the ring. The anodes are bent inwards to be soldered to pin 2, 3, 6 and 7 of the ATtiny13. A short piece of wire is connected to the common cathode and soldered to the GND pin.
The microcontroller lies “dead bug” style on the coin cell. The GND pin is bent to the top, now connecting to GND of the battery. The VCC pin is bent to the bottom and soldered to the coin cell holder. The coin cell holder works as a clip, pressing the microcontroller onto the cell.
Some random notes:
- Be patient.
- Use as less solder as possible.
- Don’t heat the pins of the controller for too long.
- Be gentle while bending the controller pins. They come off easily. I added a tiny bit of solder.
- BE patient
If you make one, please let me know. Send me a picture or post it on the tinkerlog flickr pool.
Happy third Advent …