A Four Dot Binary Clock

This
is a binary clock with an ultra-simple display. I don't think it can
get much less complex than this. No ticking, no bright LCDs or seven
segment LEDs, and no alarm. Just the time with four dots of light.
Introduction
I hate
clocks. More precisely, I hate those old ticking types that used to
infest hotel rooms. They could drive me crazy, keeping me awake all
night.
Those modern multi-digit LED, backlit LCD or
fluorescent clocks with their bright displays are almost as bad. They
seem to light up the entire room at night even if they have automatic
dimming. And then there’s that alarm function that drags me awake every
working day, and on those occasional holiday mornings when I’ve
forgotten to turn it off. Clocks – Who needs them?!
Well,
yes, we all do. So when I couldn’t read the time on my new wristwatch
in the middle of the night, the manufacturer having saved a fraction of
a cent per watch by scrimping on the ‘glow-in-the-dark’ paint on the
watch hands, I had to do something about it.
Now, any normal
person would just pop out to the nearest discount store and buy a cheap
and practical bedside clock. In my case, naturally, I had to design and
build something different.
And that’s how this clock came to be developed.
An Exercise in Reduction
The
approach used in this digital clock is very familiar, and yet the
result here, I think, is a little different. I’ve made binary clocks
before, clocks similar to the many near-identical designs which can be
found in magazines and on the Internet. These use a dozen or more LEDs
to display the clock digits simultaneously using binary coded digits
(BCD). Examples are everywhere.
I wanted to see just how
radically I could simplify a clock display while still keeping a
practical time readout. Well, this clock reduces the basic time display
to just four cheap LEDs. Four dots of light, if you will.
A
quick test with the smallest microprocessor I could find in my
parts drawer, an Atmel ATtiny25 8-pin microprocessor, demonstrated the
overall idea was practical, and the required time setting could be done
with two simple pushbuttons. This clock could be really compact.
Displaying
the time using just four LEDs might seem to be a challenge, but it
turned out to be easier than I expected.Since all of the numbers from 0
to 15 can be represented in four bits, I can display the time in hours
and minutes by displaying the time in three sequential 4-bit BCD
digits. The figure below shows an example.

As
the diagram shows, each digit in the <Hours>
<Tens-of-minutes> <Minutes> display cycle is displayed in
turn, with each digit value displayed separated by a brief period where
all of the LEDs are turned off. I added a much longer off-period
between each three-digit display cycle to clearly indicate the gap. This is repeated three times every minute.
Also,
I didn’t want these LEDs to simply appear and disappear. That felt a
bit 'agricultural' i.e. Too basic and raw for such a device. Naturally,
then, I following the increasingly common approach of making the LEDs
“breath”, each digit being displayed with a gradually rising and
falling level of brightness during each cycle.
Matching
this to the typical heartbeat rhythm, which I could pretend was to
match some subliminal circadian rhythm timing cycle but, in reality,
was the timing that just looked to me to be about right in practice,
allowed me to display three cycles of three digits every minute. So you
are never more than 20 seconds away from knowing the real time.
I
used pulse-width modulation to give the required variable LED
brightness. Since the required LED brightness during the day is greater
than at night, I added a night/day change to the cycles to ensure the
LEDs were not over-bright at night, or too dim during the day. By the
way, this added a degree of complexity to the software, so I moved up
from the small ATtiny25 to the larger ATtiny45.
Problems, problems...
However,
there is yet another problem. Not all LEDs are the made the same. That
means the three current limiting resistors used in the circuit will
need to be changed in value depending on the efficiency of the LEDs
used. All three resistors (R3, R4 and R5 in the schematic) should be
set to the same value. Based on the various LEDs that I tested (and I
checked a lot of LEDs…), I suggest using 220 ohms for older or low
efficiency LEDs and 2k2 for high efficiency LEDs.
But then the problem of powering the clock presented itself.
Running
even four LEDs nearly continuously like this will drain a tiny
coin-cell sized battery really quickly. Looking at larger batteries,
including several 1.5V AA cells and even a 9V battery, didn’t look
ideal either. And I did want the clock display to run continuously.
Many clocks turn on their display only when a button is pressed, and I
could have done that here. However, I didn’t want to be trying to find
a small ‘display the time’ button on the clock in the middle of the
night. No, I would either have to use a large battery and replace it
fairly frequently, which is hardly desirable, or run it from a small
plugpack.
So, plugpack it was. Since I have a truckload of
these from old cellphones, discarded toys and a variety of other
products, that was hardly a problem.
Having worked out the
basics of the electronics and software, I turned to the physical design
of the clock. With only four small LEDs to display, the options here
are considerable. After considering various ideas, I focused on a
simple hexagon wedge as the functional shape for the clock. This gave
me a suitable volume to house the PCB, allowing it to be placed at a
suitable angle on my bedside table for good all-round visibility. It
also permitted the thin power cable going to the plugpack to exit the
case unobtrusively at the rear, a bit like a mouse’s tail.
As
I considered the enclosure in more detail, I ended up building a few
test models using scraps of folded and glued paper. Various shapes
appeared and disappeared from my desk as I tried each in turn. Finally,
I converted the chosen design into the final version using DesignSpark
Mechanical software and printed it on my 3d printer. Despite being
mostly hollow, its overall shape and size provides enough weight to
keep it in place on the table.



Changes and Fine Tuning
There
were some other practical issues encountered enroute to this final
version. My first prototype used four high efficiency red LEDs.
However, after a week or two of testing, I discovered that the clock
was remarkably difficult to read at night. During the day, there was no
problem, but in the darkness, it was nearly impossible to make out
which bits were actually on. Being completely dark, there was no
spatial reference from any other part of the clock to act as a guide to
show which LED (or LEDs). If only one or two LEDs were on, which were
they? Bits 1 and 2? Bits 3 and 4?
The solution was simple.
I replaced the four red LEDs with a set of four distinctly different
coloured LEDs. I used a green, yellow, orange and a red LED. Now there
is no doubt which LEDs are on.
For completeness, I should
note that there are some times that might appear initially confusing,
particularly when a ‘0’ digit is involved. A ‘zero’ digit results in a
blank display of bits, of course. At 5 o’clock, for example, the digits
displayed in sequence are <5> <0> <0> and then a
longer inter-digit pause period of a blank display. That means the
clock shows just the first ‘5’ and then a long slice of nothing until
the next cycle begins. This sounds odd, but it’s perfectly
understandable once you’ve seen it.
Or what about 5:05am? This is displayed in sequence as <5>
<0> <5> and then the longer inter-digit pause. That results
in a ‘5’, a pause, another ‘5’, and a longer pause. There’s no
confusion with, say, 5:50am, given the timing, but it is different. If
nothing else, this clock will give rise to comment.
I
added two further LEDs, another yellow LED to indicate when the clock
is in the ‘time set’ mode, and a blue LED to show AM/PM (It’s turned on
for ‘PM’). These are positioned away from the main LEDs to avoid any
possible confusion. For sure, whether the time being displayed is AM or
PM is probably perfectly obvious to practically everyone, but it’s
useful for the user during the time setting mode.
The real
reason for this LED is to allow the correct time to be set. In turn,
that allows the automatic dimming function to operate correctly. The
display LEDs dim to night settings between 10pm and 6am. Recall, I
didn't want this clock to light up the entire room at night. In any
case, LEDs running at full brightness is simply not required at night.
Something like 5% of full brightness for me was about right. if that's
not OK for you, it's easy to change in the source code.Circuit Description
There’s very little to this schematic given the minimal number of parts in the clock.

The
ATtiny45 is clocked by a cheap 4MHz crystal. A crystal is necessary for
good clock accuracy. The two pushbuttons, tiny PCB-mounted momentary
switches, are connected to a single pin on the ATtiny. This pin is
placed in analog to digital (A2D) mode via the controller’s fuse
settings during programming. The A2D converter in the device converts
the voltage on the pin to a digital value. This value is read by the
controller to determine which button has been pressed.
One
down-side of this method is that the ATtiny’s usual reset function on
this pin is disabled. That also means if the reprogramming of the chip
is required, a special programmer is required. I use a Fuse Doctor to
reset and erase the chip during software development in combination
with my homemade version of the well-known USBasp programmer.
The
LEDs are driven using ‘charlieplexing’ which allows the limited number
of available pins to drive all of the LEDs. This complicates the
programming a little, but it also means I can use a small 8-pin
controller for the clock.
Many
clock designs on the Internet and in magazines use a specialized “real
time clock” chip like the Maxim DS1302 to keep time. While inherently
easier, it always strikes me as odd when there is a powerful
microcontroller chip sitting there in the same circuit controlling the
display, and often doing very little aside from just that simple job.
Such devices are readily able to keep track of the time, and in this
clock, the ATtiny45 works for its living. And it’s surprisingly
accurate. I’ve been using my clock for almost a year and I adjust it
every six to eight weeks. That's usually about the time it takes for it
to be off by a few minutes.
As mentioned earlier, power
comes directly from an external 5V supply. It requires less than 50mA
so almost any old 5V cellular phone charger can be used to power the
clock. I directly wired my power supply into circuit although the
enclosure and PCB layout has left room for a small PCB connector, if
required.
Software
The
software turned out to be a little more elaborate than I originally
expected, mostly because of the LED breathing display function. I wrote
the code in Bascom AVR because I’m inherently lazy, and Bascom is
really easy to use when I want to write some code like this quickly.
That was key at the start of the project while I was seeing if a four
dot display was actually practical.
Two timers basically
control the clock, one for time-keeping and the other controlling the
rising and falling display brightness. A lookup table determines each
step in the PWM brightness, and this also allows you to adjust it to
suit your own preferences.
The software all fits nicely into
an ATtiny45’s 4k memory. Fuse settings for the device are noted below
as well as in the source code, also available for download below. Feel
free to change the software to suit your own preferences. However,
please retain a reference in any new source code to my authorship of
the original code.
Construction
The
clock is built on a little square PCB, although a small piece of
prototyping board could also be used. Since the PCB is so simple,
it can be easily made at home in any of the usual ways. Sorry, I cannot
supply the PCB. Living as I do near the centre of one of the largest
deserts on the planet, mail services here are, well, less than
perfectly reliable.
I used a DIL socket for the ATtiny45. I also used a trimmer capacitor for one of the crystal capacitors in the prototype fearing
I’d need to adjust it to set the time exactly. As it turned out, I
found this was not required, and an ordinary disc ceramic capacitor as
used for C2 would work equally well, at lower cost.
When mounting the LEDs, position them so they are close to the front panel. This keeps the spread of light to a minimum.
The
enclosure must be then be made or purchased from one of the many 3D
printing companies that have appeared over the past few years. I made
mine from standard black PLA filament using a Printrbot Simple Metal
printer. It took me about an hour to print out the enclosure (15% fill)
along with the front panel. Another few minutes will be required to
print out the front panel artwork on a color printer. Cover it with
self-adhesive plastic film for protection. The latter can be purchased
from almost any stationary shop. Around here, it’s normally used to
cover textbooks. The LEDs shine through the paper panel artwork. This
sounds strange, but it works surprisingly well.

I've
included seven different front panel designs in the front panel artwork
available
in the Downloads section below. Print the page out on A4 paper and cut
out
the one you prefer. The one I used, shown above, is at the lower right
corner of the collection of various front panel artwork designs
available in that file.
Feed
the power supply cable into the enclosure through the small hole in the
rear of the enclosure. BEFORE you connect it to the PCB, double-check
that it is delivering 5V. Connect it to the PCB and mount the completed
PCB in place using double-sided foam tape.
Mount the front
cover onto the main enclosure using two small self-tapping screws. The
ones I used were about 3mm long and had a shaft diameter of about 1mm
or so. Something left over from recycling a small toy probably.
Depending on the hardware you use, you may need to drill out the
mounting holes slightly to ensure you don’t crack the PLA.
Check
to see that the switch cutouts on the front panel line up with the
switches. When the panel is pressed in these places, they depress
slightly inwards and activate the required switch. Just check that the
switches can function correctly. These PCB switches come with a variety
of button heights. if you happen to have switches with low-height
buttons, these can still be used. Just add a small scrap of
double-sided foam to the top of the switch buttons, keeping the
protective film on the panel-facing side so it doesn’t stick to the
back of the panel.
Operation
On
reset, the clock will start at 12.34pm. Pressing the Time Set
button will set the clock into the Time Set mode. This is indicated by
the software turning on the Time Set LED. Now, obviously, you can
set the time.
Each press of the Time Set button selects a
new digit or returns the clock to the normal mode i.e. Each press moves
the clock operating mode around a cycle from Clock – Set Hours – Set
Tens of Minutes – Set Unit Minutes – Clock.
When the clock returns to Clock mode, the Time Set LED turns off, of course.
In the Time Set mode, each press of the second (Increment) button advances the selected digit value by one.
A Final Note
Those
with a curious mind might wonder what the binary numbers on the front
panel represent. Well, they are the binary form of the ASCII characters
for C L O C K.
So, now you know.
Downloads:
Software (includes Bascom source code and compiled HEX files): Click here to download software
PCB: Click here for PCB artwork and layout
Enclosure: Click here to download the STL format 3D printer files for the base and front panel
Front panel artwork: Click FrontPanel to download the front panel artwork
Fuse Settings: See the details in the source file.
Want to go back to the main page? Click
here to
return directly.