This is only a preview of the January 2021 issue of Practical Electronics. You can view 0 of the 72 pages in the full issue. Articles in this series:
|
If you are new to using Arduinos,
perhaps initially stick with ‘official’
products – they don’t need new drivers.
The enclosure uses the baseplates
of two laser-cut boxes widely sold for
use with the Uno. I used two baseplates (as opposed to the normal top
and bottom parts) so that the top plate
didn’t have cut-outs in it. These cutouts are provided to gain access to
the pins, but I spaced the top and
bottom of the enclosure further apart
than usual (thus giving internal access
to the pins) and so I didn’t need the
cut-outs. Of course, you can use just
one box if you don’t mind the slots
in the top panel.
The top and bottom panels are
spaced 20mm apart using plastic
stand-offs, and the Uno is bolted to the
baseplate via screws, plastic washers
and nuts.
All the holes in the enclosure panels for mounting are drilled out to
3mm diameter, allowing the use of
normal-sized spacers and screws.
(As standard, these holes appear to
be 2.5mm) The side and end plates
of the enclosure are not used.
The light columns are, as described,
salvaged ballpoint pen barrels. Pick
a transparent design that has an interesting shape, preferably without
writing on it. Different barrels will
give different lighting effects; test the
result by shining a 5mm LED down
the end of the tube.
LED
SCL
SDA
AREF
GND
13
12
11
10
9
8
Anode (a)
LED
Use prewired LEDs that include
dropping resistors, or add your
own resistors (approx 470Ω to
1kΩ) to standard LEDs.
7
6
5
4
3
2
1
0
LED
Cathode (k)
An Arduino Uno and two low-cost commercially available enclosures form the main
components of the project. The upright columns are salvaged ballpoint pen bodies.
DIGITAL
UNO
ANALOG IN
A0
A1
A2
A3
A4
A5
5V
RES
3.3V
5V
GND
GND
VIN
POWER
LM35DZ
LM35DZ
1 2
1 2
VCC
VOUT
3
GND
3
Fig.1. Connection diagram for the Arduino Uno, together with the pin-outs for the two LEDs
and the LM35DZ temperature sensor. Its 5V supply is taken from the Arduino. Note: you can
use LEDs prewired with dropper resistors, or ordinary LEDs and choose your own resistor.
64
The end of the pen barrels I used
had a short length of exposed plastic thread. Two holes just undersize
of this thread diameter were drilled
in the top panel and then the plastic
pen barrels could be screwed into
the holes. A little cyanoacrylate glue
(‘superglue’) was used to secure them
into place. The pre-wired 5mm LEDs
were glued into the ends of the tubes.
Wiring
Refer to Fig.1 for the pinout of the
LM35 temperature sensor. Port A0 is
used for the signal, and the sensor’s
5V and ground connections can be
made close by on the Uno (all Uno
ports are labelled). I used header
pins and soldered the LM35 straight
to these. Ensure that the signal wire
cannot touch the ground connection.
The LEDs were wired between
ground and ports D3 and D5, again
using cut-off header pins. Remember the correct polarity for the LEDs
– positives/anodes, to the ports; negatives/cathodes to ground.
Power to the board can be supplied
via the DC socket (5-12V) or USB input.
Software
To upload the program (sketch) to
the Uno you will have first needed to
install XOD on your PC (see https://
xod.io/downloads/ – remember, it’s
free after you register). You will also
need to download the Light Column
Practical Electronics | January | 2021
Thermometer sketch from the January 2021 page of the PE website.
(Note that depending on whether
you have used XOD previously,
the software might prompt you to
do some further downloading of
extra libraries.)
Refer now to Fig.2. The beauty of XOD is that’s it very easy to
understand. In the red box (top of
diagram) we have the input from
the temperature sensor, constantly
read through Analog Port A0. This
value is multiplied by 500, averaged and then rounded. (The ‘live’
temperature is shown in the green
‘watch’ node, that operates when
the sketch is uploaded to the Uno
in ‘debug’ mode.
We now need to extract from
this number the ‘tens’ and ‘units’
– see the green box. Dividing the
value by 10 and then using a ‘floor’
node does this for the ‘tens’. Now,
what about the ‘units’? The ‘modulo’ node does this by calculating
the remainder of (again) dividing
our temperature value by ten. Two
‘watch’ nodes allow us to see these
outputs live.
Let’s do the white box next –
the flashing shows the number
of ‘units’. Our ‘units’ number is
fed to a ‘flip-n-times’ node. This
node flashes the LED output the
required number of times, and also
sets the flash rate and duty cycle –
in this case, 0.2 seconds ‘on’ and
0.5 seconds ‘off’. The ‘gate’, ‘not’
and ‘equal’ nodes then prevent
an output if the ‘units’ number is
zero. (Otherwise, the ‘flip-n-times’
node outputs one flash, even with
a 0 input.) We then feed the output
through an ‘or’ node (more on this
in a moment) and then through a
‘fade’ node. The fade node gives a
gradual (although still pretty fast)
rise and fall in LED brightness with
each flash.
Now, what about the ‘tens’? The
tricky part here is twofold: first,
the ‘units’ column needs to flash
at the same time as the ‘tens’ column when ‘tens’ are being shown,
and second, the ‘units’ can’t start to
flash until the ‘tens’ have finished
their sequence.
Flashing the ‘units’ LED when
the ‘tens’ LED is flashing is
achieved by the ‘or’ node. But what
about not starting the ‘units’ until
the ‘tens’ are done? This is done
Fig.2. The Arduino sketch for the Light
Column Thermometer is written in XOD
visual programming language. The sketch is
fully explained in the main text, but in brief,
Practical Electronics | January | 2021
the red box shows the temperature input
nodes, the yellow box extracts the ‘tens’
and ‘units’ from the reading, the white box
flashes the LED for the ‘units’ reading, the
brown box flashes the LED for the ‘tens’
reading, the yellow box starts the ‘units’
only after the ‘tens’ have finished, and the
blue box sets the cycle time.
65
|