The time shown above is 09:19:11
Clocks using hands often are called analog although no analog components are included. This clock does not even have hands, it only shows where they point to by using Neopixel modules which come in a circle shape with exactly 60 WS2812 LEDs. As a matter of fact they come in four segments, and you have to solder them together.
In this case it uses the time signal distributed by a transmitter in a place called Mainflingen (near Frankfort) at a frequency of 77, 5 kHz, which can be received by a cheap DCF77 receiver module. While there are lots of libraries to decode that signal, I developed my own code. The point is, you have to detect the time of the start and the time of the end of the pulse transmitted. This is done by an interrupt service routine (ISR) which is invoked by that pulse. When it was triggered by a RISING signal, the next cause of triggering has to be set to FALLING and vice versa. So the ISR changes the cause of interrupt itself. This is only a short extract of the real ISR:
void isr() {
long now = millis();
if (edge == START_OF_PULSE) {
risingTime = now;
long downTime = now - fallingTime;
// modify IRQ:
edge = END_OF_PULSE; // invert
attachInterrupt(IRQ, isr, edge);
}
else {
// falling:
fallingTime = now;
long upTime = now - risingTime;
// modify IRQ:
edge = START_OF_PULSE; // invert
attachInterrupt(IRQ, isr, edge);
}
}
To receive and decode the time signal it will take at least one minute, mostly more than this. At the time the DCF77 standard war introduced there was not much electromagnetic noise in the air, but nowadays you there are a lot of devices (legal and illegal ones) that produce disorders, and you will be lucky if you receive a clear signal.
In my project the clock face is shown in blue while it is still waiting for a full valid transmisson, green when a valid transmission was detected. When an error was detected, an internal clock will continue to run, and this will be indicated by showing a red clock face.
The "second" hand is indicated by showing an LED in red, the "MINUTE" hand is indicated by showing an LED in green, and the "HOUR" hand is indicated by showing an LED in blue. To make it easier to find the minute, that LED will be flashing.
The code offers to use either UNO-R3 (in this case the NANO) or UNO-R4 (in this case an R4 clone with extra headers for all IO pins) microcontrollers and DCF77-modules with either polarity. There should be a certain minimum distance between the microcontroller and the antenna because the controller itself produces some noise that will affect the quality of reception.
It must be confessed that using an R4 is a complete overkill.
RAM and ROM usage:
ROM: R3: 6192 bytes (19%), R4: 42404 bytes (16 %)
RAM: R3: 639 bytes (31 %), R4: 4092 bytes (12 %)
When mounting the segments to a board you probably want the LED numer zero on top of your board corresponding to well-known clocks where the TWELVE is located at the top position. In the picture below the lines shown in white are the horizontal and vertical ones.
So the junction between two segments has to be rotated by an angle of 3 degrees to achieve this which is shown by the black line.
My older clock projects:03.12.2021: Just another analog clock12.09.2023: R4-Wifi: Show the Time on the LED Matrix14.02.2025: Wordclock and why they are so expensive
Comments