This is only a preview of the March 2024 issue of Silicon Chip. You can view 39 of the 112 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:
Items relevant to "Laser Communicator":
Items relevant to "Pico Digital Video Terminal":
Items relevant to "‘Nunchuk’ RGB Light Driver":
Items relevant to "Mains Power-Up Sequencer, Pt2":
Items relevant to "Arduino for Arduinians":
Purchase a printed copy of this issue for $12.50. |
By Brandon Speedie
Wii Nunchuk
RGB Light Driver
Add fun to a party or a professional look to a live performance with this
RGB strip lighting driver. It is motion operated through an inexpensive
video game controller and includes a built-in strobe light.
T
he Nintendo Wii is unusual
for video game consoles as it
uses gestures for control. The
input device has buttons like a traditional controller plus a built-in accelerometer.
For example, you can hold the
controller like a racquet and make a
motion to hit a ball for a tennis game.
The “Nunchuk” is an attachment for
the main Wii controller that includes
buttons and a joystick. It is a convenient input device for this project as
it communicates via the standard I2C
two-wire serial interface, so it can
easily be interfaced with a microcontroller.
Also, the plug is a perfect fit for a
standard 1.6mm-thick PCB, so a connector can be made from the PCB
itself, without the need for a proprietary component.
There are inexpensive grey-market
clones readily available, including
UHF wireless versions for cable-free
operation.
Gestures
This project is intended to control
four strips of 12V RGB (red/green/
blue) strip lighting, as well as an array
of PCB-mounted white LEDs for strobing. Each colour in the RGB strip is
independently controlled by pulsewidth modulation (PWM), so we can
make any colour or brightnesses we
RGB Light Driver Features
» Drives up to four independent RGB LED strips
» Optional onboard white LED strobe
» Functions include variable stripe colour & brightness, strobing,
sweeping & fading
» Random sequence function
» Controlled via a Wii Nunchuk controller (wired or wireless)
» Powered from 12V DC
66
Silicon Chip
Australia's electronics magazine
fancy. Each strip can also be turned
on or off as a group, providing further
flexibility.
The PCB-mounted white LEDs have
a simple on/off control to act like a
strobe light.
We therefore have control of the
RGB strip colour, RGB strip brightness,
strip on/off and strobe on/off.
The controller has two buttons, a
joystick, and a three-axis accelerometer, with the axes shown in Fig.1. We
therefore have the following inputs:
• Joystick X-axis position (8 bits)
• Joystick Y-axis position (8 bits)
• X-axis (left/right) acceleration
(10 bits)
• Y-axis (forward/backward) acceleration (10 bits)
• Z-axis (up/down) acceleration
(10 bits)
• C (small) button on/off
• Z (big) button on/off
The angle of the joystick controls
the colour. Right (east) is red, down to
the left (southwest) is green, and up to
the left (northwest) is blue. Anything
between these positions will be a mix
of the two nearest colours (see Fig.3).
siliconchip.com.au
Y
X
Z
a 10% duty cycle (on for 10ms, off for
90ms, repeating at 10Hz).
X-axis acceleration triggers a different type of strobing called ‘channel
sweep’. If the controller is shaken left
and right, individual strips are cycled
on and off sequentially. The individual
on-time is 100ms, so it takes 400ms to
cycle through all four strips.
Y-axis acceleration triggers an automatic fade from full brightness to
off. A sharp thrust forward starts the
effect, which takes around two seconds. The lights will stay off until
the joystick is returned to the centre
position.
Circuit details
Fig.1: the Nunchuk remote used
to control the LED strips. The
acceleration of the joystick Z-axis (up/
down) controls brightness, the X-axis
(left/right) triggers the channel sweep
and the Y-axis (forward/backwards)
triggers the brightness fade.
Brightness is derived from a mixture of inputs; firstly, the position of
the joystick. When in the centre position, the lights are off. As the joystick
is pushed in any direction, the brightness increases until it is pressed fully
against a side limit, at which point we
have half brightness.
The other half of the brightness signal comes from the Z-axis acceleration.
By gesturing up and down, the brightness is throttled. The lights can therefore be ‘played’ like a drum to intuitively match the rhythm of music or
the tempo of a performance.
The Z button also affects brightness.
When held down, the Z-axis acceleration is ignored and the brightness is
solely controlled by the joystick ‘magnitude’. This can be used to force full
brightness instantly, but also for producing a subtle, steady colour without having to hold the controller stationary.
The C button controls the strobe.
When held down, the strip LEDs are
driven on (white) at full brightness,
along with the PCB-mounted white
LEDs. The flash period is 100ms with
siliconchip.com.au
The circuit is shown in Fig.2; the
brain of the operation is IC2, a Microchip (previously Atmel) ATmega32U4
microcontroller programmed as an
Arduino Leonardo. In-circuit serial
programming (ICSP) header CON2
and JTAG header CON3 are provided
for programming it.
The Nunchuk controller connects to
PCB card-edge connector (CON102),
which supplies 3.3V power to the
controller and connects the two I2C
communications lines, SDA (data)
and SCL (clock). These are connected
directly to the dedicated peripheral in
the microcontroller.
I2C is an open-drain bus, so 4.7kW
pullup resistors are provided, although
experience suggests there are internal
pullups in the Nunchuk, so they are
not strictly necessary.
Series protection resistors are provided but are usually fitted as 0W links.
Higher values could be used to provide some protection to the processor
should the Nunchuk ever be extended
to a long cable run, but I haven’t found
it to be necessary.
Footprints for two different external clock sources are provided. I used
ceramic resonator X1, but there is also
provision for a 5×3.2mm SMD crystal, X2, with the two necessary load
capacitors.
The microcontroller runs at 16MHz,
which is a bit overclocked for 3.3V
operation (the data sheet suggests a
4.5-5.5V supply for that clock rate).
Still, given that we aren’t using any of
the chip’s analog features, it shouldn’t
be a problem.
USB-C connector CON5 provides an
interface for uploading firmware and
a generic serial port for debugging etc.
Capacitive touch button S1 is made
Australia's electronics magazine
from a large copper area on the PCB.
Pressing the area with a finger cycles
through program ‘modes’, to be discussed later.
LEDs 8, 9, 12, 17, 21 & 22 are
reverse-entry LEDs ‘charlieplexed’ to
indicate to the user which mode they
are in. Charlieplexing is a technique
that we described in some detail in the
September 2010 issue (siliconchip.au/
Article/287).
It allows multiple LEDs to be driven
by a minimal number of pins that can
be tri-stated; in this case, only three
pins and resistors are required to light
any one of six LEDs.
The strip LED connectors are fourway header sockets, with pairs connected in parallel. This gives flexibility to suit different strips (for example,
to fit male and female connectors) or
simply to give more outputs to drive
more LED strips. Note that most strips
have connectors on both ends, so they
can also be extended in series.
Strip LEDs are typically constructed
with a common anode pin and individual cathode pins for each of the three
colours: red, green, and blue. To light
a colour, we need to supply +12V DC
to the anode and 0V DC to whichever
cathode we want to light up at full
brightness.
On the strip, power flows from the
anode terminal through a current-
limiting resistor and a string of three
LEDs in series before exiting the cathode terminal.
High-side P-channel Mosfets Q1,
Q2, Q3 and Q13 control the +12V drive
to the anode terminals. On startup,
they are held off courtesy of 4.7kW
gate pullup resistors.
Logic-level N-channel Mosfets Q4,
Q5, Q6 & Q14 are connected to the
microcontroller through 470W gate
drive resistors. When their gates are
driven high (to 3.3V), they conduct
and pull the gate of their corresponding high side Mosfet low, which in turn
supplies +12V to the strip.
The strip cathodes are also connected to six N-channel Mosfets,
Q7-Q12. Their gates also connect to
the microcontroller through 470W gate
resistors. These gates are PWM-driven
to provide a full colour palette.
PCB-mounted white LEDs101LED136 feature three separate dies
in a single package. There are 35 in
total, with 17 on one side and 18
on the other, as there is no LED134.
The three LEDs in each package are
March 2024 67
+12V
+12V
REG1
ZLDO1117G33TA
D1 GS1G
K
A
+
GN D
10 m F
–
VCC (3.3V)
VCC (3.3V)
OU T
IN
22 m F
1 0 0 nF
1 0 0 nF
CON1
44
24
2
+3.3V
4 .7 k W
C O N102
NUNCHUCK
AVcc
AVcc
Vcc
Vcc
UVcc
TD1/PF7
TD0/PF6
19
18
TMS/PF5
SDA
SCL
TCK/PF4
0W
ADC0/PF0
1 MW
CON5
USB-C
ADC1/PF1
PD6/ADC9
ADC11/PB4
PD4/ADC8
INT6/AN0/PE6
ADC10/PD7
IC2
ATMega32U4
0W
7
22 W
4
3
22 W
22
LED23
ADC13/PB6
VBUS
OC3A/P6
D+
ADC12/PB5
D–
PD2/RXD1
PD3/TXD1
PD5/XCK1
SS/PCINT0
470 W
PF6
37
38
PF5
39
PF4
X2
16MHz
42
X1
1 6 M Hz
6
5
ALTERNATIVES
SCLK
XTALI
MOSI
A re f
MISO
Ucap
RESET
UGND
/HWB
15
1mF
GND
23
GND
470 W
43
K
LED17
A
K
A
l
K
K
l
A
K
l
A
4.7kW
LED12
AUDIO_IN
4 70 W
ENABLE1
4 70 W
ENABLE2
28
470 W
ENABLE3
1
470 W
ENABLE4
27
470 W
RED1
12
470 W
GREEN1
32
470 W
BLUE1
30
31
29
470 W
RED2
20
470 W
GREEN2
21
470 W
BLUE2
8
STROBE
AUDIO_IN
JTAG
2 GND
PF6 3
4 VCC
PF5 5
6
VTG 7
8
PF7 9
10
C O N3
RST
0W*
GND
VCC
9 SCK
* NOT NORMALLY FITTED
10 MOSI
11 MISO
AVR ICSP
13
MISO 1
33
GND
35
LED21
l
VCC
GND
1 0 0 nF
l
40
XTAL2
1MW
17
A
A
41
l
16
l
LED8
PF4 1
22pF
22pF
CLK0/PC7
PF7
XBEE_TX
5.1kW
5.1kW
0C0A/PB7
36
K
LED9
470 W
470 W
G2
G1
A1
B12
A2
B11
A3
B10
A4
B9
A5
B8
A6
B7
A7
B6
A8
B5
A9
B4
A10
B3
A11
B2
A12
B1
26
25
CAPACITIVE
BUTTON
100nF
34
14
4.7kW
0W
LED22
MIDI, XBEE_RX
12V
IN P U T
470 W
2 VCC
SCK 3
4 MOSI
5
6 GND
RST
4 .7 k W
CON2
MISO
12
CTS
11
GND
LED7
A
9
10
8
7
6
5
3
4
l
2
470W
LED5
OPTO5
TLP290
MIDI
A
DTR
NC
PWM1
RSSI
RESET
DIO12
DIN
VCC
DOUT
470W
470W
470W
XBEE 3 RF MODULE
1
VCC
VCC
DIO4
13
14
NC
ON
15
16
RTS
ASSOC.
18
17
AD3
AD2
20
AD1
AD0
MOD1
19
MOSI
l
K
l
1
4
A
LED6
CON7
4
3
K
XBEE_TX
MIDI
IN
2
l
K
1
2
5
3
R78
XBEE_RX
VCC
VCC
SC
Ó2024
VCC
NUNCHUCK LIGHTS CONTROLLER
Fig.2: the most important parts of the circuit are microcontroller IC2 and the Mosfets it uses to drive the RGB LED strips
(connected via the headers at upper right) plus the white ‘strobe’ LEDs shown on the right. The faded-out components
are for future expansion and not needed for the features described here.
68
Silicon Chip
Australia's electronics magazine
siliconchip.com.au
+12V
+12V
4.7kW
Q4
BSS138
Q1
IRFR9010
S
G
D
D
ENABLE1
G
4.7kW
Q6
BSS138
S
G
D
D
ENABLE2
G
S
Q3
IRFR9010
4 .7 k W
Q5
BSS138
S
G
D
ENABLE3
D
G
S
Q2
IRFR9010
4 .7 k W
Q14
BSS138
G
D
Q 13
IRFR9010
D
ENABLE4
G
S
S
S
ENABLE2
ENABLE3
RED1
Q8
G
G
G
Q 7 ,Q 8 ,Q 9 ,
Q10,Q11,Q12:
MC U 3 0 N 0 2
Q7
G
TO LED138
TO LED134
TO LED139
Q11
S
LED1, LED2,
LED3 & LED4
D
D
Q9
D
S
BLUE1
TO LED4
D
D
GREEN1
TO LED137
TO LED2
TO LED3
TO LED1
ENABLE4
S
G
G
l
l
l
l
l
l
KB
LED134, LED137,
LED138,LED139
S
RED2
GREEN2
l
KG
Q 10
S
l
KR
D
S
A
Q 12
l
RED2
BLUE2
GREEN2
BLUE2
STROBE
l
l
l
l
l
l
l
l
l
VCC
A
KR
R73
KG
IC3: LMV324
KB
5
6
1mF
IC3b
7
VCC/2
LED101 – LED136 (18 TOTAL)
R72
K
l
A K
l
A K
l
A
K
l
A K
l
A K
l
A
+12V
D
STROBE
470 W
G
AUDIO_IN
Q 16
MCU30N02
S
4 .7 k W
10
NOTE: FADED COMPONENTS
WERE NOT INSTALLED ON
PROTOTYPE AND ARE NOT
REQUIRED.
9
IC3c
8
LED102 – LED135 (17 TOTAL)
R60
K
l
A K
l
A K
l
A
K
l
A K
l
A K
l
A
D
12
14
R61
K
LED18
l
LED19
l
G
13
Q 15
MCU30N02
S
4 .7 k W
1mF
R64
LED20
A
A
LED15
l
K
K
A
A
l
470 W
+12V
+12V
VCC
VCC
K
K
l
R63
A
A
A
l
R62
IC3d
STROBE
LED13
K
l
LED16
R65
1mF
4
AUDIO_RAW
1
LED14
R81
S1
ELECTRET
MIC
2
11
K
R80
R79
1mF
A
l
3
IC3a
1mF
LED11
VR100 10kW
1MW
CON100
K
A
l
K
siliconchip.com.au
R70
LED10
CON101
VCC/2
Australia's electronics magazine
March 2024 69
wired in series, with the combined
LEDs connected in two parallel sets
to +12V through 6.2W current limiting resistors.
To light them up, N-channel Mosfets
Q15 & Q16 are driven into conduction
through 470W gate drive resistors by
the microcontroller. 4.7kW pull-down
resistors ensure the LEDs are off even if
the microcontroller is not programmed
or running, and therefore has its I/O
pins at a high impedance.
LDO regulator REG1 (ZLDO1117)
creates the 3.3V supply for the microcontroller and Nunchuk from the
incoming 12V. REG1 will work with
ceramic capacitors, unlike many other
linear regulators that need some ESR
in their output capacitor to ensure stability, mandating an electrolytic type.
Diode D1 provides reverse-
polarity
protection.
It is expected that the 12V DC will
be supplied by an off-board caged type
SMPS or power brick derived from the
mains. For four LED strips, 48W (4A)
should be plenty, though I used 100W
(8.3A) as I had such a supply on hand
and it gives me the flexibility to use
more strips if I want.
I have also directly used 12V DC
from a lead-acid battery and solar
panel at a music festival where AC
mains power was not available.
Firmware operation
Much of the heavy lifting involved
in setting up the I2C peripheral and
communicating with the Nunchuk is
handled by the ArduinoWirelessNunchuk library. Once the object is set up,
all we need to do is call nunchuck.
update() to read the controller.
The joystick position is stored in
8-bit variables nunchuck.analogX and
nunchuck.analogY, giving a range of
0 (left/down) to 255 (up/right). The
values sit around 127 if the joystick
is centred.
These Cartesian coordinates are not
that useful to us; what we really want
Fig.3: this shows how the
ConvertToRGB() function converts the
joystick position to a colour in one of
six ‘bins’.
is an angle (for colour) and a magnitude (for brightness). So the first thing
we do is subtract 127 from each reading to give a centre position of 0 and
positive numbers for up/right and negative for left/down.
Then we convert to polar coordinates using √(x2 + y2) for the distance
from the centre and arctangent for
the angle:
uint8_t magnitude = sqrt(
sq(x_normalised) +
sq(y_normalised));
int16_t angle = round(atan2(
y_normalised, x_normalised)
* 180 / 3.14159265);
The magnitude is then summed
with the z-axis acceleration to give
a final brightness figure between 0
and 255. If the Z button is being held
down, we double the magnitude value
rather than summing it with the Z-axis
acceleration.
We now have our colour defined
in the HSB (hue, saturation, brightness) colour system. Hue is our joystick angle, brightness is our joystick
magnitude + z acceleration, and saturation is hard coded to its maximum
for the most vibrant colour. We then
Table 1 – hue ‘bins’ (b = brightness, h = hue[°] ÷ 60)
Bin #
Hue range
Red (0-255)
Green (0-255)
Blue (0-255)
0
0-59°
b
b×h
0
1
60-119°
b × (2 – h)
b
0
2
120-179°
0
b
b × (h – 2)
3
180-239°
0
b × (4 – h)
b
4
240-299°
b × (h – 4)
0
b
5
300-359°
b
0
b × (6 – h)
70
Silicon Chip
Australia's electronics magazine
convert to the RGB colour space using
convertRGB(), which works by segregating the brightness into one of six
‘bins’ based on hue.
Each bin is selected as hue(°) ÷ 60
to give a full colour wheel (see Fig.3).
With saturation at maximum, the
six bins are calculated as per Table 1.
These red, green and blue magnitudes are then used to update the
PWM outputs. This firmware uses the
Arduino’s built-in analogWrite() function, which provides 8-bit resolution
at 490Hz.
For the strobe, it looks at the status
of the boolean (true/false) variable
nunchuck.cButton. If true, the c button
is being pressed. Variables to control
the on and off time of the strobe are
loaded with the current time, plus a
user-configurable offset:
strobe_on = now + STROBE_DUTY;
strobe_off = now + STROBE_
DURATION;
By default, STROBE_DUTY is 10
milliseconds and STROBE_DURATION is 100 milliseconds, although
they can easily be changed to suit
the application. If the current time
(“now”) is less than strobe_on, the
strip LEDs are driven to full brightness
on all three colours, giving a bright
white. The PCB-mounted white LEDs
are also switched on.
If the current time is greater than
strobe_on, we are in the off period
between flashes, so all outputs are
driven low. If the present time exceeds
strobe_off, the off-period has elapsed,
and we need to begin the cycle again.
Variables strobe_on and strobe_off
are loaded with new values and the
flash repeats.
Channel sweep works similarly.
If the X-axis acceleration (left/right)
value is below X_THRESHOLD
(default 20), we know the controller is being shaken vigorously. The
‘resting’ value is 512 (around half
the 10-bit limit of 1023), so 20 corresponds to a high acceleration in the
negative direction of the axis. The
time when that threshold is crossed
is stored in memory, and the channel
sweep starts.
The current time is then compared with the previously saved
time, and if the difference is more
than CHANNEL_SWEEP_PERIOD
(default 100ms), we know to cycle to
the next LED strip. Channel sweeping
works by turning off all but one of the
siliconchip.com.au
high-side Mosfets that feed the LED
strips with +12V. By turning these on
or off sequentially, a visually appealing strobing effect is achieved.
Similarly, the automatic fade works
by checking if the Y-axis acceleration (forward/backward) is below
Y_THRESHOLD (default 20). If the
controller is thrust forward sharply,
this limit will be exceeded and the
brightness will subsequently be set
to maximum.
For the fade program cycle, the
brightness is then decremented by
FADE_STEP (default 5) until it reaches
zero. This achieves a fade from full
brightness to black in around two seconds. The lights will stay off until the
joystick returns to the centre position,
at which point colour_sweep_retrigger is unlatched and normal operation resumes.
The firmware also supports an automatic mode. The LED strips will go
through a random sequence without
user input. The mode is cycled using
the capacitive touch button.
A square wave is applied to this
pad by a pin on the microcontroller.
A separate pin senses the voltage on
the copper pad. The time it takes to
charge and discharge this copper area
is proportional to the capacitance of
the pad, which changes if a finger
touches it. That is sensed in the software as a button touch, which cycles
through modes.
For more on how that works, see
my March 2015 article on an Arduino Touch Shield (siliconchip.au/
Article/8386).
The current mode is indicated
via the reverse-entry LEDs LED21 &
LED22. Only those two are currently
driven by the firmware, although six
are provided for future expansion.
Three pins drive the Charlieplexed
LED array.
In auto mode, the brightness and
hue are randomly generated through
Arduino’s built-in pseudo-random
number generator function, random().
Once a new random value is calculated, the current brightness and hue
will slowly ramp towards those values. When it reaches them, new numbers are generated. This gives a continuously variable LED brightness
and colour.
Construction
Begin by soldering all components
to the PCB, referring to the overlay
siliconchip.com.au
Parts List – RGB Strip Lighting Driver
1 double-sided PCB with black solder mask coded 16103241, 213 × 158mm
1 220 × 160 × 80mm ABS plastic enclosure [Altronics H0313 or H0333]
1 high-current 12V DC power supply
1-4 RGB LED strips [Altronics X3213A or X3328]
1 Wii Nunchuk or compatible controller, wired or wireless
1 16MHz 3-pin SMD ceramic resonator, 3.2 × 1.3mm (X1)
[CSTNE16M0V530000R0]
1 2-way 10A+ 5/5.08mm pitch terminal block (CON1)
1 3×2 pin header (CON2; optional, for in-circuit programming of IC2)
1 5×2 pin header (CON3; optional, for JTAG programming/debugging of IC2)
1 Molex 2171790001 16-pin USB Type-C connector (CON5)
4 4-pin right-angle headers, 2.54mm pitch (LED1, LED2, LED138, LED139)
Semiconductors
1 ATmega32U4 8-bit micro programmed with 1610324A.HEX, TQFP-44 (IC2)
1 ZLDO1117G33TA 3.3V 1A low-dropout regulator, SOT-223 (REG1)
4 IRFR9010 50V 5.3A P-channel Mosfets, TO-252/DPAK (Q1-Q3, Q13)
4 BSS138 50V 220mA N-channel Mosfets, SOT-23 (Q4-Q6, Q14)
8 MCU30N02 20V 30A N-channel Mosfets, TO-252/DPAK (Q7-Q12, Q15, Q16)
3 green SMD LEDs, M3216/1206/SMA size (LED21-LED23)
35 Cree CLP6B-WKW-CD0E0233 cool white LEDs, PLCC-6 (LED101-LED136)
1 GS1G 400V 1A diode, SMA/DO-214AC (D1)
Capacitors (all SMD M2012/0805 size unless noted)
1 22μF 25V X5R M3216/1206 size
1 10μF 50V X5R M3216/1206 size
1 1μF 50V X7R
4 100nF 50V X7R
Resistors (all SMD M2012/0805 size 1% unless noted)
1 1MW
2 5.1kW
9 4.7kW
17 470W
2 22W
35 6.2W 1W M6332/2512 [eg, Panasonic ERJ1TRQF6R2U]
4 0W
diagrams, Figs.4 & 5. The double-sided
board used is coded 16103241 and
measures 213 × 158mm.
There are components on both sides,
although most mount on what will
become the underside. Quite a few
components are for future expansion
and were missing from our prototype,
so we suggest you leave them off too.
They are shown faded out (transparent) in Figs.4 & 5 and are not in the
parts list.
As a general rule, start with the lowest profile SMD parts and work up to
the larger through-hole components.
All can be soldered by hand, but a
reflow oven and solder paste can also
be used for the SMD components if
that is your preference.
For those who haven’t tried it, a hot
plate also works surprisingly well. It
may sound crude, but laying your PCB
into a foil-covered pan on the stove is
very effective. For many years, I have
used a standalone electric hot plate
for this purpose, and it has been well
worth the $20 investment.
Fit all the SMDs on the bottom side
first. If soldering by hand, start with
IC2 by applying flux paste and then
Australia's electronics magazine
dragging a tinned chisel tip across the
quad flat pack pins.
The larger SMD components, such
as power Mosfets Q1, Q3 etc and
low-dropout regulator REG1, are easiest done next by applying a small
amount of solder to the large copper
area and leaving the iron to heat the
area for several seconds. The component can then be placed using tweezers.
Ceramic resonator X1 can be
mounted similarly; all three pads can
be heated simultaneously.
Next, solder all passives. All resistors and capacitors are M2012/0805
size (2.0 × 1.2mm) or larger, so they
are manageable by hand. I prefer to
first wet one pad with solder, place
the component with tweezers, then
solder the other pad once the first has
set and the component is held in place.
Finish the SMD parts by soldering the
SOT-23 transistors, diode D1 and the
reverse-entry LEDs.
Note that the LEDs must face down;
they shine through holes in the PCB.
Now flip the PCB over and solder
the 6-pin PLCC strobe LEDs. This is a
challenging component to solder due
March 2024 71
Figs.4 & 5: most of the parts are mounted on what will become the underside of the PCB (inside the case). The PCB is
attached to the case like a lid, so only the components on the top, including most of the connectors and the capacitive
button, are externally accessible. Note how the LEDs all mount on the bottom side but they shine through holes in the
board so they’re visible from the top. The 0W resistor (labelled in red) connected to CON3 is only fitted if you want the
reset line to also pull down the test reset, for this application it does not need to be fitted.
72
Silicon Chip
Australia's electronics magazine
siliconchip.com.au
This is the side of the board that’s externally visible when mounted in the case. This overlay shows all 35 white
LEDs fitted; if you don’t need the strobe to be super bright, you could install a subset of those. I included the 17 evennumbered white LEDs on my prototype and it was bright enough for me.
siliconchip.com.au
Australia's electronics magazine
March 2024 73
to its high thermal mass. If your soldering iron has an adjustable temperature, I recommend you turn it up to at
least 400°C, then work your way along
the six leads individually. The solder
must flow down the leg onto the pad,
so apply heat for several seconds to
ensure proper wetting.
Finish the PCB by soldering the
through-hole components: the LED
strip headers and screw terminals. If
you are planning on modifying the
firmware, install USB-C connector
CON5. Start with the through-hole
pins that hold it in position, then solder the SMD signal pads using the
same drag method as for IC2.
Power supply
We recommend using an external
12V DC ‘brick’ supply since that’s the
safest and easiest option. You don’t
need to do any mains wiring. All you
need to do is wire up its output (with
the correct polarity!) to CON1.
As we’ve recommended that you fit
CON1 on the underside of the board,
you can drill a hole in the side of the
box and run the wire in through a
grommet and directly into the terminals of CON1.
You could use a chassis-mount DC
socket and plug, but watch the current
ratings of the wiring, socket and plug
to ensure they can handle the full output of your supply.
While it’s possible to install a mains
to 12V DC switch-mode power supply
in the base of the box (using a metal
baseplate like Altronics’ HA0312A
that suits the specified cases), we
won’t explain how to do that. You
would need to be careful to anchor
the mains cable (or use a socket),
use mains-rated wiring and plenty
of insulation and cable ties to keep
it safe.
For portable use, one good battery
option is to use Makita 12V lithium-
ion battery packs. They are readily
available at hardware stores; you can
keep a few charged ones with you
while you’re on the go. You can also
use them with their power tools! I
got the socket from AliExpress for
$15 (siliconchip.au/link/abrh), and it
works well.
Now you can attach the PCB to the
top of the enclosure. It takes the place
of the enclosure lid in this design and
is attached using the screws that come
with the case.
Finishing it off & using it
If you got your microcontroller from
the Silicon Chip Online Shop, it will
already be programmed. However, if
you used a blank chip, you will need
to flash the Arduino bootloader onto it
via ICSP header CON2 or JTAG header
CON3, using a hardware programmer.
If you don’t have a hardware programmer, some low-cost options are:
• Duinotech ISP Programmer (Jaycar XC4627, $14.95)
This is an early prototype, so I had to make some modifications, including
rerouting a couple of tracks. The final version of the board presented here won’t
require those changes.
74
Silicon Chip
Australia's electronics magazine
siliconchip.com.au
• Pololu USB AVR Programmer v2.1
(Core Electronics [CE] POLOLU-3172,
$26.05)
• SparkFun Tiny AVR Programmer
(CE PGM-11801, $33.32)
• SparkFun Pocket AVR Programmer (CE PGM-09825, $33.25)
• USBasp USBISP AVR Programmer (CE 018-USB-AVR-ISP, $10.95)
If you have a spare Arduino, you can
repurpose it as a hardware programmer using the “Arduino ISP” project
– see siliconchip.au/link/abri
Make sure the Leonardo is selected
in Tools → Board and select your programmer from Tools → Programmer.
You may also need to select the serial
port for the programmer. Then use
Tools → Burn Bootloader to turn the
blank chip into a Leonardo.
Our article on repairing an Uno goes
into more detail on ISP programming
the processor on an Arduino board
(March 2020 issue; siliconchip.au/
Article/12566).
Once flashed, the microcontroller
should automatically appear as a virtual serial port when plugged into a
computer via the onboard USB port.
If not, drivers can be manually downloaded and installed from the Arduino website (siliconchip.au/link/abrj).
Once you have that working, the firmware can then be uploaded via the USB
port using the Arduino IDE.
You should now have a functioning
product. Plug your Nunchuk controller into the PCB, ensuring the connector is orientated correctly (notch facing
up) – see Fig.6.
Plug in your RGB LED strip(s), and
you should be ready to perform! A bit
of practice is required to get familiar
with the controls, but before long, it
begins to feel natural. Once comfortable with the basics, you will find
yourself combining multiple controls
to give a more compelling experience.
Experience suggests the Z button
works well with the channel sweep,
Fig.6: the correct orientation for the
Nunchuk controller plugged into the
PCB connector. Note how the notch is
facing up.
and sparing use of the C (small) button
in combination with the Z-axis acceleration to add interest.
A final word of advice: much like
the rest or pause in music, sometimes
periods of darkness can add emphasis.
SC
Less is more!
I only fitted the white strobe LEDs on one side of the board, but you will get a
brighter strobe if you add them on both sides. The board name was also changed
to a slightly less ‘silly’ one during development.
siliconchip.com.au
Australia's electronics magazine
March 2024 75
|