This is only a preview of the December 2025 issue of Silicon Chip. You can view 35 of the 104 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Articles in this series:
Articles in this series:
Items relevant to "RGB LED Star Ornament":
Items relevant to "Earth Radio, Part 1":
Items relevant to "DCC Decoder":
Items relevant to "Digital Preamplifier, Part 3":
Purchase a printed copy of this issue for $14.00. |
Nicholas Vinen
Adjustable brightness and ambient auto-dimming using an LDR
Adjustable pattern cycle time
Mostly pre-assembled; can be up and running in under an
hour
Power supply: 12V DC recommended <at> 1-2A (operating
range: 6-16V DC)
SC7535 Kit ($80)
Includes a pre-assembled PCB with
nearly all parts fitted, except for IC1,
REG2 etc (see the parts list)
24cm tall and wide white star-shaped PCB
80 onboard bright WS2812B RGB LEDs in a star/circle pattern
12 different LED light patterns, each with four possible colour
palettes
Manual or auto-cycling patterns and palettes
Jazz up your Christmas tree (or just about anything else) with this luminous RGB LED
Star. It has 80 “NeoPixel” LEDs that create an array of dazzling, colourful patterns.
You can choose which patterns and colour schemes you like, adjust the brightness and
more. It’s quick and easy to build, too!
siliconchip.com.au
Australia's electronics magazine
December 2025 41
Y
ou can watch a video of some
of the available patterns and
colour schemes at siliconchip.
au/Video/RGBStar
It has been a few years since we’ve published a Christmas ornament project,
despite those generally being very popular. Partly it’s because people were
still building our previous designs.
However, while making more kits
for the November 2020 RGB LED
Christmas Star, we had two realisations. Firstly, it had been five years
since we published that design. Secondly, it’s a lot of work to build, but
people obviously think it’s worthwhile
as they continue to order kits for it.
It uses 30 individual RGB LEDs,
with four pins to solder on each, plus
90 current-limiting resistors, 13 driver
ICs, more than 20 bypass capacitors
and some other sundry parts. Assembling the board would take most of a
day. That got us thinking: was there
an easier way?
Our first thought was WS2812B
“NeoPixel” LEDs. These devices have
GND and Vcc pins plus serial data
input and output pins (four in total).
The Vcc and GND pins are all joined in
parallel, while the output of one LED
goes to the input of another, forming a
daisy chain (you may well have seen
these on RGB LED strips).
That means you only need one pin
on a microcontroller to drive many
– possibly even hundreds – of these
devices. They’re bright and can display one of 16,777,215 different
colours. By writing clever software on
a microcontroller, we could generate
all sorts of cool patterns using a string
of these devices. So what’s not to like?
Our concerns were that they are
SMD-only and, if you buy them individually and put a lot on a board, the
cost can add up. However, there is a
solution to that: get the PCB manufacturer to solder the LEDs for you.
That saves a lot of work and gives a
neat, professional result. Also, because
they have access to huge quantities
directly from the manufacturer, it
can be cheaper than buying individual parts and soldering them yourself.
Down the rabbit hole
So we set to work designing a PCB
for this, with four questions immediately popping up. What shape, size
and colour should the board be, and
how many NeoPixel LEDs should we
put on it?
We liked the star concept, but
weren’t sold on the five-pointed star
used in the November 2020 project we
mentioned earlier. Partly that was out
of a desire to do something different,
but also, five-pointed stars don’t look
right to us.
Of course, real stars don’t have
points; they are distant, bright spheres
that should look like a point source.
It’s the optical imaging system (a telescope, or perhaps our eyes) that makes
them appear to have points. Usually,
those points are arranged symmetrically, meaning there are an even number of them.
Fig.1 shows an image from the James
Webb Space Telescope where you can
see that its optics generate six lines
that appear to emerge from the star’s
point source. To cut a long story short,
we decided that a more realistic and
cool-looking star would have four long
and four short points, with the short
points offset by 45°.
We also decided to make the board
white, for two reasons. Firstly, to differentiate it from the earlier star, which
was black, and secondly, because the
original WS2812B LEDs came in white
plastic packages. (Black ones are now
available, but let’s put them aside for
another day.)
As for the size, we were able to
design a board with that shape that
wouldn’t be too expensive to manufacture by making it 238mm tall and
238mm wide. The trick is to rotate the
design by 45° so that it fits inside a 168
× 168mm square, as that’s the basis
on which the manufacturers charge
(238mm ÷ 168mm ≈ √2).
Having drawn the board shape, we
arranged a string of LEDs around the
edge of the star shape, plus two rings
inside, ending up with 80 LEDs in
total. That seemed like a reasonable
number to generate some interesting
patterns. So the mechanical side of
things was sorted out, and it was time
to turn to the electronics!
Power delivery and control
Fig.1: stars look like more than just points because of the optics viewing them
(eg, a telescope or our eyes). The lines that appear to radiate from them are
normally symmetrical, meaning an even number, and some are longer than
others. Hence the shape of our Star, with four long points and four short ones.
At full brightness, set to produce
white light, each LED draws around
50mA. Multiply that by the 80 LEDs
and we can see that we need to deliver
around 4A at 5V to run them all. That’s
a substantial amount of power: 20W.
Of course, this isn’t a torch, so we
would never actually drive them all
white at once. The actual average
power required would be a more modest 10W or so; 2A at 5V. And that’s
assuming you would run it at full
brightness, which, to get a bit technical, is eye-searingly bright. Most people would run it close to 5W of total
LED power.
Still, the 10W figure could be delivered by a reasonably efficient 2A buck
(step-down) regulator running from a
higher voltage, like 12V. The same 5V
supply (or a separate one) could then
run a microcontroller to generate the
patterns.
Besides the LEDs, the micro and
power supply, we would also need
a decent number of bypass capacitors spread around the board. The
WS2812B LEDs control brightness
Australia's electronics magazine
siliconchip.com.au
42
Silicon Chip
using pulse-width modulation (PWM),
meaning there will be constant switching spikes distributed around the
board. So we’ll want a few ceramic and
perhaps tantalum polymer capacitors
to keep the 5V rail nice and stable.
All that would be left would be a
few buttons and perhaps trimpots
to do things like adjust brightness,
change the patterns, set up pattern
auto-cycling and such. Add an LDR
to monitor the ambient light level for
auto-dimming, and the design was
complete.
Getting it assembled
As mentioned earlier, our plan was
to order some prototype PCBs and have
the manufacturer fit the WS2812B
LEDs for us. We would then add the
power supply, microcontroller and a
few other bits and pieces to finish it off.
The power supply and microcontroller could go on the back of the board,
so they wouldn’t mar its appearance,
meaning only one side of the board
needed to be pre-populated.
We figured we could also get them
to place the bypass capacitors for the
WS2812Bs on the same side, as they
would not ruin the appearance as long
as we placed them symmetrically. But
we’d leave fitting all the other parts
for ourselves (or someone else building this later). As we went through
this process, we discovered that the
WS2812B LEDs require “special
handling” because they have a high
moisture-sensitivity level (MSL5).
Automated/contract PCB assembly
is usually done using solder reflow,
where solder paste is melted in an
infrared (IR) oven, or wave soldering,
where a wave of molten solder passes
over the surface of the board and some
sticks to the exposed pads and pins.
In both cases, the components rapidly heat up from room temperature to
about 250°C over a few minutes. They
sit at the high temperature for just long
enough to let all the solder melt and
reflow, then they are cooled back down
to close to ambient temperature. The
whole process takes about 4-6 minutes.
If any components on the board contain moisture (water), that water will
flash boil and rapidly expand. The
result can be exploding components
– not what you want. So they have to
be dry before you start; either removed
from a hermetically sealed package
just before soldering, or baked in an
oven at a lower temperature (90-125°C
siliconchip.com.au
Parts List – RGB LED Star Ornament
1 white 168 × 168mm double-sided star-shaped PCB coded 16112251
1 12V DC 1A+ (2A recommended) power supply ×
1 2-pin header or right-angle header (CON1; optional) •
1 5-pin header or right-angle header (CON2; optional, for ICSP) ×
1 3-pin header or right-angle header (CON3; optional, for testing) ×
2 6A 18mW (120W <at> 100MHz) SMD M3216/1206 ferrite beads (FB1, FB2)
[Tai-Tech HCB3216KF-121T60]
1 2.7A 33μH shielded SMD inductor, 12 × 12mm (L1)
[Sunltech SLH1204S330MTT]
1 GL5528 20kW-1MW LDR (LDR1) •
3 6 × 3mm two-pin SMD tactile pushbutton switches with white actuators
(S1-S3)
2 10kW Bourns TC33X-2-103E SMD trimpots (VR1, VR2)
Semiconductors
1 PIC16F18126-I/SL 8-bit 14-pin microcontroller programmed with
1611225A.HEX, SOIC-14 (IC1) •
1 LDL1117S50R or AMS1117-5 low-dropout 5V linear regulator, SOT-223
(REG1)
1 AP5002 20V 2A 500kHz integrated buck regulator, SOIC-8 (REG2) •
80 WS2812B-V5 serial RGB “NeoPixel” LEDs, SMD 5050 (LED1-LED80)
1 AO3400A 30V 5.8A N-channel Mosfet, SOT-23 (Q1)
1 BZX84C5V6 5.6V ±1% 250mW SMD zener diode, SOT-23 (ZD1)
1 BZG05C-5V6 5.6V ±6% 1.25W SMD zener diode, DO-214AC (ZD2)
1 B340A or S3A 40V 3A SMD schottky diode, DO-214AC (D1)
Capacitors (all 50V SMD X7R MLCC, M3216/1206 size unless noted)
1 220μF 25V polymer aluminium electrolytic capacitor, 6.3×6mm SMD
[Shengyang SM227M025E0600]
6 220μF 6.3V polymer tantalum electrolytic capacitors, SMB case
[Panasonic 6TPE220MAZB]
12 22μF 25V X5R
1 22μF 10V SMA tantalum [Kyocera AVX TAJA226M010RNJ]
31 100nF
1 4.7nF
1 1nF
Resistors (all ±1% SMD M3216/1206 size)
2 100kW
1 10kW
2 6.8kW
1 1.3kW
1 1kW
1 330W
RGB LED Star Kit (SC7535, $80 + P&P): comes with a pre-assembled PCB
with all parts fitted except those marked with • or ×. The parts marked • are
included in the kit but must be fitted by the constructor.
for 24-48 hours) to drive out all the
moisture before soldering.
So, we had to pay a little extra to
get the WS2812B LEDs for our prototype boards baked. That meant we
needed to choose the ‘standard’ assembly service rather than the ‘economic’
one. The standard service also allows
you to put components on both sides
of the board. Hmm. It was starting to
look like we might as well get virtually
the whole thing assembled!
One of the parts we chose to use, the
buck regulator controller, is no longer
being manufactured (we’ll explain
why we chose it a bit later). We have
hundreds, but didn’t feel like sending them to the manufacturer, so we
decided to solder it ourselves. It’s only
an 8-pin device in a relatively large
Australia's electronics magazine
SOIC package, so not difficult for us
or any other constructor to add.
We also left the PIC16 chip that
produces the patterns off the assembled board. It’s also in an SOIC package (with 14 pins, though) and we figured we could supply programmed
chips that constructors could easily
fit to the board. We also didn’t have
them put any headers on it, since we
figured people might have different
preferred arrangements for wiring up
the power supply.
Other than that, though, all our prototype boards – and the ones we’ll supply to readers – come with almost all
the parts fitted. So assembly is quick
and easy, despite the large number
of LEDs! This also helps to keep the
total cost to build it down, since the
December 2025 43
manufacturer can source these parts
in bulk from their partner warehouse.
As a result, we can supply a kit that
includes the mostly assembled board,
programmed microcontroller and
switch-mode chip, ready to assemble,
for around $80 + P&P.
That is somewhat more than the $45
we charge for the November 2020 RGB
LED Star kit, but considering the time
savings in not having to assemble the
whole thing yourself from well over
one hundred parts, the larger PCB,
larger number of LEDs, better patterns and brightness, it ends up being
a pretty good deal.
But for those intrepid constructors,
the blank PCB will be available separately, if you want to assemble the
whole project yourself.
Circuit details
The full circuit of the RGB LED Star
is shown in Fig.2. By showing only
some of the long chain of LEDs, we
manage to keep it relatively simple. It
can be broken into three main blocks:
the LEDs, the microcontroller and the
power supply.
Microcontroller IC1 drives
the chain of LEDs (LED1LED80) via its RA2 digital
output and a 330W series
resistor, as recommended
in WS2812B data sheets to
reduce overshoot and ringing from trace inductance
and limit fault current
into the first LED.
Each LED’s output
drives the subsequent
LED input until LED80,
which is loaded with a resistor to
ground to reduce the chance of any
ringing or EMI from an unterminated
output pin.
A total of 42 bypass capacitors scattered around the board, in three different values, provide local bypassing for these 80 LEDs. In total, they
can draw up to 4A (!), and they dim
the LEDs using PWM, so we want to
ensure they see a low 5V supply source
impedance.
Test header CON3 gives us a way
to drive the LEDs before IC1 is soldered to the board, should we need
that. Most constructors will not need
to fit it.
The user controls are three pushbuttons, S1-S3, and two trimpots, VR1
& VR2; the buttons connect to digital
inputs RC0-RC2 (pins 10-8). The software in IC1 enables a weak pull-up
current on these pins so they are normally held high, at around 5V. When
a button is pressed, it pulls that pin
to 0V, transitioning to a digital low, so
the software can sense that. Debouncing is performed in software.
When VR1 & VR2 are rotated, they
vary the voltages at pins 3 & 2 of IC1
between 0V (fully anti-clockwise) and
5V (fully clockwise). IC1 uses its internal analog-to-digital converter (ADC)
to convert these voltages into numbers
between 0 and 4095, to control the
overall brightness and the duration of
each different pattern, respectively.
Another analog input, ANC5 at
pin 5, connects to the junction of a
light-dependent
resistor (LDR1)
and a fixed
100kW resistor.
The voltage at this
pin will be higher
The front of the LED Star
includes two buttons to
change patterns.
44
Silicon Chip
in bright ambient lighting conditions
and closer to 0V in darkness. Again,
the ADC is used to sample this voltage
to provide auto-dimming, so the LEDs
are not so bright at night, but bright
enough to see clearly during the day.
At 100% brightness, the RGB LED
star is eye-searing! So we definitely
need both manual and automatic
brightness control.
Five-pin header CON2 can be used
to program IC1 in-circuit. We used
this during development, but since
kits/boards will come with a pre-
programmed microcontroller, you
won’t need to fit it unless you want
to design your own patterns or otherwise make changes to the firmware.
Power supply
Power comes in via a two-pin header
(CON1) or soldered wires shown at
upper left. Mosfet Q1 and zener diode
ZD1 provide reverse polarity protection without dropping much voltage.
If the polarity is correct, Q1’s gate is
pulled high, switching it on and providing a low-resistance path between
the negative conductor and ground.
If the polarity is reversed, Q1’s gate
is pulled negative. It remains off, and
its intrinsic body diode is reverse-
biased, so no current can flow. The
Mosfet is rated at 30V, and ZD1 clamps
its gate voltage at a safe level, so nothing will happen with a negative voltage up to -30V applied to the circuit.
The maximum positive voltage is limited to 18V by REG1.
One 220μF aluminium polymer
electrolytic capacitor and two 22μF
ceramics provide bulk storage and
bypassing for the input of REG1, an
LDL1117 5V low-dropout regulator.
This is a true low-dropout regulator,
and it will provide a regulated 5V
rail for the microcontroller
as long as there’s at least
5.5V at its input. It also has
a 22μF tantalum output filter
capacitor, required for stability.
Its 5V output is only used to power
the microcontroller and connected
components like the LDR and trimpots. This means that the switching noise from the LEDs doing their
PWM brightness control won’t affect
the microcontroller’s analog measurements.
The remainder of the power supply
is a DC/DC converter that supplies the
high-current 5V rail for the LEDs. It is
based around REG2, an AP5002 ‘2A
siliconchip.com.au
Fig.2: the PIC16F18126 microcontroller at lower left controls the 80 LEDs by sending serial data from its RA2 digital
output. The LEDs have plenty of bypass capacitors of various sizes to provide them with the peak current they draw
during operation. The power supply at the top includes reverse-polarity protection (Q1/ZD1), a linear regulator to power
the micro (REG1) and a switch-mode step-down buck regulator (REG2) to power the LEDs from a ~12V DC source.
buck’ converter. This chip is obsolete
now, but we like it so much that we
bought several hundred, so we will
supply them with boards/kits (or separately, if you really need one for some
other reason).
Some of the reasons we are still
using this is that it is easy to solder,
coming in an 8-pin SOIC package with
no thermal pad underneath; it has a
useful range of voltages (up to 20V)
and currents (it says 2A but can actually deliver 4A or more in some cases),
can go to 100% duty cycle (meaning
it’s a ‘low dropout’ buck regulator!)
siliconchip.com.au
and it’s up to 90% efficient. We also
find that it ‘just works’.
One of its nice features is an external
compensation network that requires
just two or three components. This
is one of the keys to its stability in a
wide range of situations. We’ve used
it in a few projects before, such as the
Simple 1.2-20V 1.5A Switching Regulator (February 2012; siliconchip.au/
Article/774) and the CLASSiC DAC
(February-April 2013; siliconchip.au/
Series/63).
Now, while in theory the LEDs could
draw up to about 4A if they were all
Australia's electronics magazine
at 100% brightness and set to white;
this is not a torch, so that’s unlikely to
happen. In general, this regulator will
see a load below 2A <at> 5V; perhaps a
little higher in extreme cases. So, the
internal switch current limit of 3.5A
and L1’s rating of 2.7A are not really
of concern (especially since L1’s current rating is saturation-based, not
thermal).
Since we’re recommending a 12V
DC input and we’re producing a regulated 5V (more like 4.9V, actually) for
the LEDs, REG2 is operating near its
sweet spot, around 90% efficiency (its
December 2025 45
Fig.3: the star has been
rotated 45° to fit on the
page; the upper-left corner is
intended to be the top. All
the components you see here come
pre-soldered to the board except for
LDR1, in the centre. Some holes at lower- right allow you to attach it to a stick or the
top of a Christmas tree.
2A headline rating is more of a ‘worstcase scenario’, thankfully).
We have ferrite beads at the input
and output of the DC/DC converter
section to try to reduce the amount of
switching hash radiated from either
end. FB2 is also convenient in that if
you run into problems, you can remove
it to disconnect the output of the DC/
DC converter from the LEDs, allowing
you to test them in isolation.
Zener diode ZD2 is not strictly necessary; it’s a ‘belts and braces’ protection measure. Should there be positive spikes from the output of REG2
for some reason (eg, the load suddenly goes from 4A to 50mA and it
can’t switch off fast enough), ZD2 will
46
Silicon Chip
conduct once the LED supply exceeds
about 5.5V, limiting the supply rail to a
safe level of about 6V in the short term.
PCB design
The top side of the assembled board
is shown in Fig.3. The only part you
need is add here is the LDR at the centre. The first LED in the chain, LED1,
is towards upper left. You can follow the snaking path of the data from
there clockwise around the star, back
to LED56 just below LED1, then to the
circle formed by LED57-LED72, and
finally the smaller concentric circle
formed by LED73-LED80.
Note how there is a polymer tantalum capacitor on each of the longer
Australia's electronics magazine
‘arms’ of the star, plus two in the middle, for distributed bypassing. The
eight points of the star also feature a
22μF bypass capacitor, plus numerous
100nF capacitors scattered throughout so that all LEDs have a low source
impedance.
Most of the copper on the top of
the board is a +5V distribution plane,
with the underside copper being GND.
Hence, there are pairs of vias near the
GND end of most components to connect them to the ground plane.
The star is intended to be rotated so
that LED5 is at the top. There are holes
at each long point (eg, for hanging it),
plus some extra holes on the bottom
one so that a stick or similar can be
siliconchip.com.au
Fig.4: the control and power
supply circuitry is located
in the centre of the back of the
Star. The DC/DC converter
delivers 4.9V DC at up to several amps
to the centre of the board, where it’s
conducted out to the LEDs arrayed around it by copper planes; the front of the board
has the +5V (4.9V) plane while the GND plane is on the back side.
attached for holding it up (shown with
M2 machine screws in them in some
of the photos).
Turning to the underside (Fig.4),
you can see that the power supply
and control components are clustered in the centre, divided by fivepin header CON2. The control components are above and to the right
of CON2, while the power supply is
below and left. The power connections
(CON1) are near the bottom of the star,
so any attached wires can hang down
behind it.
A slight revision
We made just a couple of minor
changes to the design between the
siliconchip.com.au
prototype and the final version. Firstly,
we added a 220μF 25V low-ESR aluminium polymer capacitor across the
input of the linear regulator, REG1,
visible on the left in Fig.4. This is to
overcome any lead inductance from
the power supply, suppress ringing
and provide a local charge reservoir
for the switch-mode regulator.
While the prototype worked without
it, we felt that it was worthwhile adding, especially since the part only costs
about 10¢. We also added another 22μF
ceramic capacitor in parallel with it
for higher-frequency stabilisation of
the input supply.
Finally, we decided to replace
the boring old AMS1117-5 regulator
Australia's electronics magazine
(REG1) on the prototype with the more
modern LDL1117S50R.
This is a direct drop-in replacement,
as it’s in the same SOT-223 package
and has the same pinout. However, it
is a true low-dropout regulator that can
withstand a higher input voltage (18V
vs 15V), with a lower quiescent current
(0.25mA vs 5mA), so we thought it was
a worthwhile upgrade (the required
tantalum output capacitor upgrade
costs more than the regulator).
Construction
When you receive the board, it
should have all the top-side components fitted besides LDR1, and all the
underside components fitted besides
December 2025 47
the three pin headers (all of which are
optional), IC1 and REG2.
It will also have a pair of ‘rails’
attached to it, which were used to
hold it during the assembly process
(see the photo below). There is a series
of holes drilled between the rails and
the PCB edges (‘mouse bites’). These
allow you to easily snap the rail off
by flexing the junction back and forth
a few times.
The breaks should be fairly clean,
but if you want to, you can clean them
up with a file. Just make sure you don’t
breathe the resulting fibreglass dust
(eg, do it outdoors and ideally while
wearing a mask, or at least with the
wind blowing it away from you).
Testing
Our prototypes worked straight
away, so really the easiest way to
proceed is to solder LDR1, IC1 and
REG2 to the board, making sure IC1
& REG2 are orientated correctly, then
apply power and check that it lights
up and start producing some nice LED
patterns. However, if you want to test
it more methodically, you can (as we
did with our prototypes initially, just
to be safe).
Firstly, you can solder CON3 to the
board. If you don’t want it visible on
the front of the Star, you can either
solder wires to the pads on the rear,
or remove it later.
Connect CON3’s terminal
marked + to the output of a
bench supply. Short the
The LED Star has some M2-sized
mounting holes, for if you want to
attach it to something solid.
other two pins together and connect
them to the negative output/ground.
Set the current limit to 100mA, the
voltage to 5V and apply power. Our
board drew 40mA in this condition,
exactly what was expected when powering 80 LEDs with 0.5mA quiescent
current each.
This verifies that there are no short
circuits or faulty components among
the LEDs or their bypass capacitors.
Next, solder to the pads of CON1.
You can use a right-angle header on
the rear of the board if you have the
type of right-angle header you
can solder from the same
side, such as a polarised right-angle
header. Alternatively, solder the wires
to the board.
Apply 7-12V DC and you should
see a current draw of around 5mA
if you have an early board with the
AMS1117, or 0.5mA if you have the
LDL1117 regulator. Use a multimeter
to check the voltage between pads 1
& 14 of IC1. You should get a reading
close to 5V.
Now remove power and solder
REG2 to the board (remember what
we said earlier about getting its orientation right!). One side is quite close
to D1, but we managed to solder the
pins on that side without bridges
by bringing the iron in from above.
Good news: pins 5 & 6 are connected
electrically, as are pins 7 & 8, so as
long as you don’t get a bridge across
the middle two pins on that side,
it’ll be fine!
Place a jumper on CON3 between
the middle and ground pins (ie, not
on the + side). This holds the input
to LED1 low. Now apply 6-12V via
CON1 and measure the voltage across
the pins on either side of CON3, being
careful not to short anything. You
should measure close to 4.9V DC, and
the current draw should be around
50mA.
If all is good, switch it off and solder IC1 to its pads, again checking its
orientation carefully. This should be
easy as there aren’t any components
too close to its pins, but check for
solder bridges and if you find any,
remove them with flux paste and solder wick.
Because parts are soldered to both sides of
the PCB, it needs to be manufactured with
rails, as shown here. They are used to hold
it in place during soldering. When you receive it, you can flex them back
and forth a few times carefully and they will snap off. If you want to clean up
the rough edges left behind, it’s easy to do with a file, but don’t breathe the dust.
48
Silicon Chip
Australia's electronics magazine
siliconchip.com.au
The finished underside of the RGB LED star is shown on the right,
with a close-up shown inset. This inset photo shows the missing parts
that you need to fit yourself, but are included in the kit.
If IC1 hasn’t been programmed,
you can attach CON2 and a PIC programmer and upload the firmware
(1611225A.HEX). But since you most
likely bought an assembled board, it
will come with a pre-programmed
chip, so you are ready to power it up
properly using a high-current (capable of at least 1A) 12V DC supply at
CON1 and you should be rewarded
with colourful patterns.
Using it
By default, it will cycle through all
12 possible patterns and four colour
palettes at an interval determined
by the setting of trimpot VR2. Fully
anti-clockwise will make it cycle
roughly once per second, while fully
clockwise will give you around five
minutes per pattern. VR1 will adjust
the overall brightness, and the light
level on LDR1 will also affect the
brightness.
You’ll need a jeweller’s slotted
screwdriver or a similarly slim tool to
rotate the small screws of the two trimpots. Note that there are no stops; they
rotate through 360° but they only work
properly over about ¾ of that travel.
So if you get flickering when adjusting
VR1, or odd behaviour when adjusting VR2, you’re probably off the track.
Pressing S1 briefly will switch
to manual pattern selection mode.
Each further press of S1 will cycle to
the next pattern. Once pattern 12 is
reached, pressing S1 will go back to
pattern 1.
siliconchip.com.au
Similarly, pressing S2
briefly will switch to manual
palette selection mode. Each
further press of S2 will cycle
to the next palette. Once the
fourth palette is reached, pressing S2 will go back to the first.
The auto-cycling works
mostly independently for patterns and palettes, meaning you
can have both change automatically periodically, or just one or the
other, or neither. To resume auto-
cycling the pattern, hold down S1 for
a couple of seconds. To resume auto-
cycling the palette, hold down S2 for
a couple of seconds.
If both are set to cycle, when it’s
time to cycle, the unit will select the
next enabled pattern with a random
palette. That way, you get to see different patterns with different palettes.
You can disable some patterns or
palettes if you don’t like them. To disable the current pattern (regardless
of whether it’s auto-cycling or manually selected), hold S2, then quickly
press and release S1, then release S2.
It will go to the next enabled pattern,
and the last pattern will be skipped
from now on.
You can’t re-enable individual patterns since you can’t select them, but
you can re-enable them all by holding
down S2, then pressing and holding
S1 for a few seconds, and then releasing S1 before S2.
Similarly, to disable the current
palette, hold S1, then quickly press
Australia's electronics magazine
S2, release S2 and then S1. It
will go to the next enabled palette, and the last palette will be
skipped from now on. You can’t
disable the last pattern or palette,
though. To re-enable all palettes,
hold down S1, then hold down S2
for a few seconds, then release S2,
then S1.
There is a third switch on the back
of the board labelled S3. It can be used
to change the LDR setpoints or disable
automatic brightness control. Usually,
VR1 sets the maximum brightness, but
it will be reduced if the LDR senses a
low ambient light level. By default, it
will be reduced to a very low setting,
around 5% of maximum, in complete
darkness.
To change that, adjust VR1 to get the
minimum brightness you want, then
press S3 briefly. You can disable auto
brightness adjustment by holding S3
for a couple of seconds; then only VR1
sets the brightness. Setting the minimum re-enables it.
You may want to temporarily disable auto brightness when adjusting
VR1 to set the minimum since it’ll
remove the effect of ambient light
while you are making the setting.
If you find that too much of the light
from the LEDs shines on the LDR, making its brightness control unstable or
ineffective, you could shrink a short
section of black heatshrink tubing
around it to shield it from light from
the sides. That way, it should only
react to ambient or reflected light. We
December 2025 49
didn’t need to do that, but since the
LDR calibration is automatic, it must
be exposed to both light and dark
before it will sense properly.
Firmware operation
The firmware is written in C and
split into five files:
• neopixel.c is the main program
that includes pin configuration,
peripheral configuration, button,
potentiometer and LDR sensing, user
interface logic, LED update code and
the main loop.
• LEDs.c contains 320 bytes of data,
stored in flash, on the locations of the
80 LEDs on the physical PCB for use
by the effects code.
• rgb.c contains helper functions
that generate the four colour palettes
and perform RGB colour mixing.
• trig.c contains an integer sine
table and sine/cosine functions for
trigonometric effects.
• effects.c contains the logic to
implement the 12 separate patterns
that can be displayed on the LEDs.
Some effects are based on the locations of the LEDs in the chain, some
on their Cartesian (X/Y) coordinates on
the PCB, and some on their polar (distance/angle coordinates) on the PCB.
For example, effect #1 is a gradient
that snakes its way along the chain
of LEDs from LED1 to LED80. It is a
nice-looking effect but the simplest to
implement.
Effect #3 is coloured circles that
radiate from the centre of the star,
out the points, and then end. It uses
the polar coordinates, comparing the
distance of the LED from the centre
of the board to the current radius of
the circle.
Effect #5 is a colour spectrum that
rotates around the display like a spinning wheel. It is similar to effect #1,
but it uses the polar angle of the LED
rather than its position in the chain.
Effect #10 is coloured bubbles that
grow from random points within the
star and then burst. It calculates the
distance of an LED from the centre of
a bubble using the formula distance =
√(x1 – x2)2 + (y1 – y2)2.
The effects are double buffered,
meaning that the processor is calculating the next state of the LEDs to
show (into buffer x) simultaneously
with transmitting the last update to the
LED string (from buffer y). The buffers
are swapped on each run through the
SC
main loop.
50
Silicon Chip
Updating Neopixels using the CLC hardware
We got this idea from Microchip Application Note AN1606 “Using the Configurable Logic Cell (CLC) to Interface a PIC16F1509 and WS2811 LED Driver”. Unfortunately, the CLC peripheral in modern PICs is configured quite differently from
the PIC16F1509, so the code in that App Note is no longer very useful.
Also, we realised it’s unnecessarily complex – using two CLCs when the job
can be done with just one (possibly due to improvements in the CLCs since it
was written).
The difficulty in driving WS2812B chips is that they use a somewhat unique
scheme that encodes 0s and 1s into different-length positive pulses. Interestingly, different versions of the WS2812B, even within the same manufacturer,
have different specifications for what is required. As shown in Fig.a, the specific
version we are using (V5) requires:
Zero bit: 220-380ns high, 580-1000ns low
One bit: 580-1000ns high, 580-1000ns low
Reset frame: low for at least 280μs
Note how this scheme is difficult to encode with a system that emits bits at
consistent intervals. A zero bit lasts for 800-1380ns and a one bit lasts for 11602000ns. So, to have consistent bit intervals, the interval must be between 1160ns
(862kHz) and 1380ns (725kHz).
If you select an interval in the middle of, say, 1250ns (800kHz), that means you
could have a one bit with a 50% duty cycle, ie, 625ns high and 625ns low. The
high time for the zero bit would need to be at least 250ns to avoid the low time
exceeding the 1000ns threshold, giving you a range of 250-380ns.
We use the MSSP peripheral to generate an 800kHz SPI stream as the basis
for this signal. This gives us an SCK signal that’s high for 625ns and low for
625ns, and an SDO signal that’s either high or low for 1250ns depending on the
value of the bit being transmitted.
We feed both of these to a CLC cell, along with a synchronised PWM waveform
that has a high time of around half the SCK high-time at ~312.5ns – see Fig.b.
Fig.a: there are quite a few WS2812B variants, and they all seem to have slightly
different timing requirements (sometimes compatible with each other, sometimes
not). We’re using the current V5 variant; its timing is shown at upper right here, with
the data formats (common to all variants) below. The timings in the lower part of the
diagram are nominal.
Australia's electronics magazine
siliconchip.com.au
Fig.b: we’re using the MSSP serial
peripheral, CCP PWM generator and
CLC configurable logic cell in the
PIC to generate the WS2812B signal
with minimal CPU overhead. Writing
a byte to a buffer triggers the MSSP
to generate eight bits of data. We
combine its clock (SCK), serial data
output (SDO) and synchronised PWM
signal with the CLC to make the
orange waveform the LEDs expect.
That time of year is nearly here...
CHRISTMAS
Spice up your festive season
with eight LED decorations!
Luckily for us, it’s possible to synchronise the MSSP to a PWM peripheral by setting the SSPM bits in the
SSPxCON1 register to a value of 3 (SPI
Host Mode: Clock = TMR2 output/2).
TMR2 is also the default clock source
for a Capture/Compare/PWM (CCP)
Module, which can be set in PWM
mode. So we can synchronise the
leading edge of the PWM pulses with
the leading edge of the SCK pulses.
We can then use the CLC to perform the simple logic operation (SDO & SCK) | PWM. The SDO & SCK operation
produces 625ns positive pulses if the data bit is a one or no pulse if the data
bit is a zero. By ORing this with the PWM pulses, which overlap with the start of
the SCK pulses, we either get a 625ns pulse if the data bit is a one or a ~300ns
pulse if it’s a zero – see Fig.b.
Unfortunately, there’s no good way to stream multiple bytes of data out using
the MSSP module; it only has a single buffer register (SSPxBUF) and you can
only initiate a transfer by writing a byte to it when the peripheral is not already
transmitting data.
We solve this by setting up a timer (Timer 4) to run from the main oscillator
with a period of 82, which is just a tiny bit longer than it takes the MSSP peripheral to transmit one byte. By initiating a series of byte transfers in the interrupt
service routine (ISR) triggered by Timer 4, we create an effectively uninterrupted
stream of data to update all the LEDs with minimal processor overhead.
Excluding the setup code, that means we only need the following code to
update all 80 RGB LEDs.
## Additional code required to update all LEDs
void __interrupt() isr(void) {
SSP1BUF = *RGBBufPtr;
if( ++RGBBufPtr == RGBBufEnd )
PIE2bits.TMR4IE = 0;
PIR2bits.TMR4IF = 0;
}
static void StartTransmission
(unsigned char* start, unsigned char* end) {
RGBBufPtr = start;
RGBBufEnd = end;
while( PIE2bits.TMR4IE )
;
TMR2 = 0;
TMR4 = 0;
PIE2bits.TMR4IE = 1;
}
This is the basic code used but it lacks the 280μs reset timer after each
transmission, implemented with a separate timer peripheral.
siliconchip.com.au
Australia's electronics magazine
Tiny LED Xmas Tree
54 x 41mm PCB
SC5181 – $2.50
Tiny LED Cap
55 x 57mm PCB
SC5687 – $3.00
Tiny LED Stocking
41 x 83mm PCB
SC5688 – $3.00
Tiny LED Reindeer
91 x 98mm PCB
SC5689 – $3.00
Tiny LED Bauble
52.5 x 45.5mm
SC5690 – $3.00
Tiny LED Sleigh
80 x 92mm PCB
SC5691 – $3.00
Tiny LED Star
57 x 54mm PCB
SC5692 – $3.00
Tiny LED Cane
84 x 60mm PCB
SC5693 – $3.00
We also sell a kit containing all
required components for just
$15 per board ➟ SC5579
December 2025 51
|