It has become a kind of tradition for me to create something interesting for the winter holidays, using LEDs and microcontrollers.
This time I chose to create 5 different PCB designs, representing winter holiday motifs: a snowman, a Christmas tree, a bell, a lollipop to hang on the tree and, of course, a Christmas tree, all decorated with specific winter elements and and colored differently, depending on the variety available from the PCB manufacturer.
These can be used in three ways (or more, depending on each person's imagination): earrings, pendant or decoration to put on the Christmas tree.
DescriptionThis project consists of a small LED-illuminated Christmas decoration controlled by the PIC10F322 microcontroller. The goal is to achieve attractive visual effects, but with low power consumption, so that it can be powered by batteries for a longer period.
Microcontroller: PIC10F322, 6-pin SOT-23 package
Oscillator: internal, 4 MHz
Programmer: Microchip SNAP (low-voltage programmer)
LEDs: 3 red + 3 orange
Connection method: Charlieplexing on 3 GPIOs → 6 LEDs possible
Reset pin: used as reset, not as GPIO, due to SNAP limitation (cannot apply high voltage for reconfiguration). The pin is pulled up with a 100 kΩ resistor.
Power supply: battery, with an emphasis on energy saving; type CR1225
Assembly: all components were hand-soldered to the board
The program is written in MPLAB X using pic-as assembler (v3.00). The main lighting effects implemented are:
- fade in/out software PWM: LEDs gradually turn on and off, creating a breathing effect.
- rapid sequences: each LED lights up one by one or in a cascade, 6 times consecutively, for a dynamic effect.
To conserve energy: the microcontroller enters sleep mode for 8 seconds, using the watchdog as a timer between lighting cycles.
The decoration offers a warm, red and orange play of lights, perfect for the Christmas atmosphere. The small size of the microcontroller and the charlieplexing method allow for a minimalist but effective design.
Battery consumption and life estimationThe battery used to power this decoration is the CR1225 type. I chose this battery because it is small and weighs very little and thus does not burden the project, if it is used as earrings.
This CR1225 battery has a nominal capacity of approximately 50 mAh. The LEDs used have a pulse current of approximately 4.5 mA using 220ohm resistors in the charliplex structure.
The life of a battery in continuous operation would be between 3 and 8 days.
Details: the current code runs only 2 routines: program_1 and program_3 (see the code structure in mplabx, attached).
A. Program_1 runs 6 PWM loops, 500ms pauses and fast flashing of each LED (2 times). Thus:
- the complete PWM loop (fade In and OUT) takes approx. 2.5-3 seconds;
- the 6 PWM loops take 3x6 = 18 seconds.
All Delays in program_1 are: 14 x Delay_500ms + 10 calls to Delay_500ms from the fast flashing loops (Flickers) = (14 + 10) x 0.5s = 12s
Therefore, the total time for program_1 is 18s + 12s = 30s
B. Program_3 runs 6 Circular_right cycles and 6 Circular_left cycles, each blink having a delay of 2 x 50ms + On/Off time.
The time for each Circular loop (left and right) is: 6 LEDs x (2x50ms) = 0.6 s
Total time of Circular loops = 12 x 0.6s = 7.2 sec
Total time for program3 is: 7.2s + 1s (2 x Delay_500ms) = 8.2s
C. The total time the MCU is active is: 30s (program_1_ + 8.2s (program_3) = 30.2s.
D. Sleep mode = 8s
Average Consumption Calculation:
A. In sleep mode I_sleep ~= 1 microA;
B. In activ mode I_activ: since the LEDs are turned on using PWM at a peak current of approx 4-5 mA (Charlieplexing), the average consumption over the 38.2 seconds is estimated at approx 150 microA (including the MCU at 4 MHz and the LEDs with medium duty cycle).
I_activ_med = [(I_activc T_activ) + (I_sleep x T_sleep)] / (T_activ + T_sleep)
I_activ_med = [(150 microA x 38.2 s) + ( 1 microA x 8 s)] / 38.2 s + 8 s) =
=... ~= 124 microA
Estimating total battery life
Using the capacity of CR1225 battery of C_bat ~=50mA:
Duration (in hours) = C_bat / I_activ_med = 50 mA / 0.124 mA ~=403 hours
Duration (in days) = Duration (in hours) / 24 hours/day = 403 / 24 ~=16.8 days
Realistic Adjustment: Since intense PWM and high peak currents degrade the effective capacity of coin cell batteries (P_rated effect), a more realistic estimate that takes these losses into account would be: approx 3 to 8 days.
Programming the decorationFor this year I created quite a large number of such decorations for Christmas, 50 boards (10 pieces of each type), so programming them takes some time.
This time I chose not to use through hole terminal connector to connect the Microchip SNAP programmer (it would have looked at least ugly, like this, each PCB with 5-6 holes); instead, I added on the PCB, on back side of the decoration, (before starting the routing) 6 pads aligned at 2.54mm, on 2 rows, and I used a POGO connector, 2x3 for programming; to this connector I soldered 5 connecting wires with the SNAP programmer, so that, by pressing lightly with one hand, I managed to perform the programming in a fast manner.
Below is the POGO connector and the connecting cables to the Microchip SNAP programmer:
The programming pins and connections between the programmer and the MCU board are shown below, with the mention that the pads used for programming have the same configuration for all types of decorations created.
Here are all 5 types of decorations presented, to see how they look in the end, how they are decorated on the front and how the electronic components are arranged (the position of each component is visible in the project created with EasyEDA, for each decoration, attached):
Below you will see how these decorations work, in two situations: in natural daylight and at dusk:
Next steps...






Comments