HackSpace – September 2019

(Jacob Rumans) #1
LENS

YOU’LL NEED


‘BIG BEN’ CLOCK
 ÇothinǼ eʯtrƃ

INTERNET OF THINGS
 ̧ĄM : ̧Ý:¶
 Arduino Ethernet
shield
 Ethernet cable
MŽAŽ ŽÇĀĩT
 Optoisolator
6N138
 5-pin DIN
ӯMŽAŽӰ ɰoƺȟet
breadboard-compatible
 Resistors
220Ω0Ω0PΩ
 Diode
1N4148

The next logical addition for either the chiming clock or
the Internet of Things alarm clock would be a display to
show the time. Perhaps the most obvious component for
this would be a four-digit, seven-segment display, as used
in digital clocks since the 1970s, although a more modern
OLED display could also be cool, as could Nixie tubes or
edge-lit LED displays, sometimes known as ‘Lixies’.

Adding a display


This first modification is a nice one to start with,
because we can make it without any extra
components. By making some changes to the code
in the Arduino sketch, we can tell the instrument to
play a melody at a specific time, rather than on the
push of a button.
We’re going to trigger a melody every 15 minutes,
making a chiming clock à la Big Ben (although Little
Ben might be a more apt name for our tiny clone).
Download the glock_clock sketch and have a look at
it – the code starts off pretty similar to the main build,
but there are a few additions and changes.


The single, long noteSequence array in the previous
version has been replaced by a two-dimensional array
containing four separate lists of notes – these are the
four different melodies played by Big Ben. Below this
we have also defined variables representing the
current time in hours and minutes – you need to set
these manually to the current time before uploading
your sketch (e.g. if the time is 3:47 pm, set
startTimeHours to 15 and startTimeMinutes to 48,
then upload the code to the Arduino just as the
minute hand ticks over from 47 to 48). Once your
sketch is running, it should stay approximately in time,
and the chimes can be turned on or off by pressing
the button.


We’re going to trigger


a melody every 15


minutes, making a


chiming clock


Big Ben chiming clock


Left
;he NSoJRenspieS
Jan Ie proNraTTed
to TiTiJ )iN )en’s
MaTous TeSod`
Credit
+a]id 3iMM
** )@:( 3
Free download pdf