This is only a preview of the January 2025 issue of Silicon Chip. You can view 38 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. Items relevant to "Digital Capacitance Meter":
Items relevant to "Compact HiFi Headphone Amp":
Articles in this series:
Items relevant to "Gesture-controlled USB lamp":
Items relevant to "BIG LED clock":
Items relevant to "40A Current Probe":
Items relevant to "Battery-Powered Model Train":
Items relevant to "TCS230 Colour Sensor":
Purchase a printed copy of this issue for $13.00. |
Mini Projects #018 – by Tim Blythman
SILICON CHIP
Gesture-Controlled
USB Lamp
We designed this circuit to work with a lamp,
but it could control just about any USB-powered
device (rated at 5V). You could add an IR receiver
for IR remote control, or an LDR to make it an
automatic night light. By waving your hand over
the small purple module, you can switch power to
the USB socket; perfect for controlling a USB lamp.
B
ack in March 2022, Jim Rowe
wrote about gesture recognition
modules such as Jaycar’s XC3742.
These nifty little modules are capable
of recognising about 10 different hand
gestures using an integrated IR pixel
array (siliconchip.au/Article/15247).
Now, we’re using this module to
control a USB lamp. Since this project switches power to a USB socket, it
could be used to switch any number
of devices that run from USB power.
You can see a video of it working at
siliconchip.au/Videos/Gesture+Lamp
We built it on a prototyping shield
that sits above a Leonardo main
board. That makes it easy to tweak
the circuit if you wanted to make
modifications.
Circuit
Fig.1 shows the circuit. Apart from
the Leonardo board, all the parts
shown there are fitted to a prototyping
shield. There are two sections; on the
right is the gesture recognition module, while on the left we have the USB
power switching circuit.
The wiring to the gesture recognition module is simple enough. It just
needs connections from 5V, GND,
SDA and SCL to the module, which
incorporates the I2C pullup resistors
and a voltage regulator to power the
onboard chip.
We’re using a pair of transistors to
switch power to the USB socket’s positive (5V) pin. The ground pin is permanently connected. Pin A0 (which
can be used as an analog input) is
configured as a digital output. This
keeps the wiring on the prototyping
shield neat.
When A0 is pulled high, about
Parts List – Gesture-based USB Lamp (JMP018)
1 Arduino Leonardo [Jaycar XC4430]
1 Arduino prototyping shield [Jaycar XC4482]
1 Hand Gesture Recognition Module [Jaycar XC3742]
1 1kW 5% (or better) axial ¼W (or more) resistor [Jaycar RR0572]
1 120W 5% (or better) axial ¼W (or more) resistor [Jaycar RR0550]
1 PCB-mounting USB Type-A socket [Jaycar PS0916]
1 TIP32 40V 3A PNP transistor, TO-220 [Jaycar ZT2290]
1 BC546, BC547, BC548 or BC549 100mA NPN transistor, TO-92
[Jaycar ZT2154]
1 30cm length of insulated wire in various colours [Jaycar WH3032]
1 USB-A to micro-USB cable to suit the Leonardo board
1 USB-powered light or similar device to control
48
Silicon Chip
Australia's electronics magazine
4mA flows through the 1kW resistor
and base-emitter junction of the NPN
transistor, so it switches on and allows
current to flow through its collector to
its emitter.
This, in turn, causes about 40mA to
flow through the PNP transistor’s base
via the 120W resistor, which switches
it on as well. That means that 5V is
available at the USB socket to power
a connected device.
When A0 is held low, both transistors are off and there is no voltage at
the USB socket. It might seem unnecessary to have two transistors, but this
arrangement provides enough drive
to the PNP transistor to ensure it is
switched fully on and does not drop
any significant voltage. It also means
that our input at A0 is intuitive; a high
level swiches the output on and a low
level swiches it off.
The circuit operation depends on
firmware loaded on the Leonardo,
which we will discuss later.
Construction
We built everything on a prototyping shield to create something reasonably robust. You should be able
to see how everything is wired up
from the photos. We’ve used yellow
wires for 5V connections, since red
could be difficult to see against the
red shield PCB.
There is no significant wiring under
the shield, so everything is visible from
siliconchip.com.au
Fig.1: all parts of this circuit apart
from the Leonardo board are fitted
to a prototyping shield. It supplies
5V to the USB socket on the left
when the A0 pin is brought high.
above. The only thing to note is that the
four wires connecting to the gesture
recognition module do so underneath
the shield, connecting to the immediately adjacent wire in each case.
We’ve positioned the USB socket
to make use of the IC breakout pads
on the shield. It also means that the
USB input (to the Leonardo) and the
output (on our shield) are at the same
end, making external connections
tidier. That puts the gesture sensor at
the other end, where it can be accessed
easily.
Start by soldering the header onto
the gesture module and then solder it
to the shield. We lifted ours up slightly
so it sits just below the top of the shield
header sockets.
Run the four connecting wires next.
There is a yellow wire from 5V on the
shield to Vcc on the module, as well as
a single black wire for ground (GND)
and two blue wires for SCL and SDA.
Make sure those are routed as shown.
Refer to the photo of the USB sockets that show how we’ve bent the two
large tabs outwards. That allows them
to be soldered to the top of the shield.
The four smaller pins should slot into
the pads with a bit of wiggling; the
pad spacing is not quite the same as
the pin spacing on the socket, but it
is close enough.
We have left a row of pads behind
the USB socket so that wires can be
attached there. Add a generous amount
siliconchip.com.au
of solder to the larger tabs to give them
some mechanical strength, then solder
the four smaller pins.
Next, fit the two transistors, being
careful with their orientation. In our
photos, from left-to-right, the pins are
(for the PNP transistor) emitter, collector, then base, followed by (for the NPN
transistor) collector, base and emitter.
The photo overleaf shows the wiring
most clearly, also check that your wiring matches the circuit.
Next, add the two resistors, with
the 1kW resistor going from A0 to the
NPN transistor’s base and the 120W
resistor going between the PNP transistor’s base and the NPN transistor’s
collector.
Follow with the remaining wires as
shown in the photos. Note that some
5V and GND connections are made on
pads near the USB socket. They should
be marked, but you can carefully follow the copper traces on the prototyping shield to be certain.
Finally, plug the completed shield
into the Leonardo and connect it to a
computer for programming.
Software
The sketch is quite simple and
just needs one external library for
the gesture sensing; we used one of
the same libraries Jim used back in
2022. It can be installed by searching
for “RevEng_PAJ7620” in the library
Bend the tabs on the USB socket as shown here (on the right) so they can be
soldered to the top of the prototyping shield. This will provide the needed
mechanical strength for devices being plugged and unplugged.
Australia's electronics magazine
January 2025 49
Silicon Chip
PDFs on USB
¯ A treasure trove of
Silicon Chip magazines on a
32GB custom-made USB.
¯ Each USB is filled with
a set of issues as PDFs –
fully searchable and with
a separate index – you just
need a PDF viewer.
¯ Ordering the USB also
provides you with download
access for the relevant
PDFs, once your order has
been processed
¯ 10% off your order (not
including postage cost) if
you are currently subscribed
to the magazine.
¯ Receive an extra
discount If you already
own digital copies of the
magazine (in the block you
are ordering).
EACH BLOCK OF ISSUES COSTS $100
NOVEMBER 1987 – DECEMBER 1994
JANUARY 1995 – DECEMBER 1999
JANUARY 2000 – DECEMBER 2004
JANUARY 2005 – DECEMBER 2009
JANUARY 2010 – DECEMBER 2014
JANUARY 2015 – DECEMBER 2019
OR PAY $500 FOR ALL SIX (+ POST)
WWW.SILICONCHIP.COM.
AU/SHOP/DIGITAL_PDFS
50
Silicon Chip
Follow the wiring to match our circuit (Fig.1). The wires for the gesture
module connect to their adjacent pads under the PCB. That is the only
wiring on the underside of the shield PCB. You can also see the generous
solder blobs that we have added to the USB socket to secure it to the board.
manager. Alternatively, you can install
the zipped copy we are including with
the software package, which can all
be downloaded from siliconchip.au/
Shop/6/526
The sketch initialises the sensor.
If that fails, the Leonardo’s onboard
LED flashes. Otherwise, the software
monitors the sensor, switching on the
USB output with an ‘up’ gesture and
off with a ‘down’ gesture.
The Leonardo’s onboard LED also
indicates the on/off state, while other
debugging information is available on
the serial terminal. Some of the values
that correspond to other gestures are
listed if you wish to change the default
behaviour.
To program the Leonardo board,
open the sketch in the Arduino IDE,
choose the correct board in the dropdown menus along with its serial port
and then upload the sketch.
The sketch and circuit should
work without changes with the Uno
Australia's electronics magazine
R3 board instead of the Leonardo,
although we have not tested that.
Testing
While connected to your computer,
wave your hand above the module and
verify that the Serial Monitor reports
the gesture correctly. We found that
moving our hand about 10cm above
the sensor worked well. You will
also see the Leonardo’s onboard LED
switch on and off.
Plug a USB device into the socket
and confirm that it operates as
expected. If all is well, you can plug
the Leonardo into a USB power supply to untether it from your computer.
The transistor and thus USB socket
can deliver about 1A at most; of course,
that will depend on your power supply
being able to provide enough power. In
our testing with a 500mA lamp, there
was no noticeable temperature rise in
any of the components.
SC
siliconchip.com.au
|