Arduino Voltmeter Clock
In this Instructable I will show how to build a desktop clock my means of three voltmeters analogue displays and an Arduino Nano.
The idea is not original – you can find many similar projects on internet – but I try to keep it as simple as possible, and to describe a general method to use any analogue display.
The correct time can be set with just two buttons (to regulate hours and minutes), and the clock can be powered either with a battery or an external power supply.
Supplies
- 3 x analogue displays
- 3 x 5 or 10 kOhm potentiometers
- 3 x few micro-Farad electrolytic capacitors
- an Arduino Nano
- 2 x buttons
- 2 x 1 to 4 kOhm resistors
- a wood box
- wires
facultative
- 9V battery
- 5 Volt power supply with its socket
- breadboard
Arduino Code
At the bottom of this chapter you can find the Arduino code.
In brief: the Arduino begin to count the time in milliseconds starting from the initial switching ON, and you can get them with the command millis().
With the following instruction:
secondsTot = (offsetOre*60 + offsetMin)*60 + offsetSec + long(millis()/1000);
you get the total seconds from the start, after adding two offsets (hours and minutes). These offsets are set incrementally by pressing the buttons.
After that the code evaluates the analog value for the voltmeter hand of hours and minutes with the following commands:
seconds = long(secondsTot) % 60;
minutes = long(secondsTot/60) % 60;
hours = long(secondsTot/3600) % 12;
minutesAnalog = minutes + float(seconds)/60.;
hoursAnalog = hours + minutesAnalog/60.;
and finally send them to the voltmeters with the following analogWrite commands, to the Arduino pins 9, 10 and 11 respectively.
analogWrite(11, 3 + int(1.0*seconds/60.*256));
analogWrite(10, int(1.0*minutesAnalog/60.*256));
analogWrite(9, 8 + int(1.0*hoursAnalog/12.*256));
Note that the analogue output accepts values from 0 to 1023, and returns an analogue voltage from 0 to 5 Volts. The 256 factor, in the upper formulas, limits the maximum voltage to 1.25 Volt. More details in the next chapter.
Downloads
Analogue Display Calibration
According to your display model, you may need to further decrease the voltage from 1.25 Volt to a fraction of a Volt. You can decrease the Arduino output, for instance replacing the factor 1.0 in the previous formulas, to a bit smaller value. But it cannot be too small, if you want to preserve the dynamic range 0 to 256 and move the display harm continuously.
For instance, for the following values: analogWrite(11, int(0.2*seconds/60.*256)); you have output from 0 to 51, thus steps smaller than the seconds scale, which is divided by 60 steps, of course.
In the upper drawing, it is shown how to connect a general voltmeter display to its Arduino output Da = 9, 10 or 11 for hours, minutes or seconds respectively.
The 5 or 10 kOhm potentiometer shown in the schematic, acts as a Voltage divider and may be needed for displays that need a very small input voltage.
Consider the following example for the seconds (Da = pin 11):
1) To calibrate the end position of the seconds hand just replace the seconds analogWrite with:
analogWrite(11, int(x*256));
and try different values of x or regulate the potentiometer.
2) To calibrate the start position of the seconds hand just replace the seconds analogWrite with:
analogWrite(11, y));
and try different integer values of y, do not change the potentiometer. This calibration may be needed since the Arduino output needs a small offset to begin to generate a voltage.
3) Finally, once yo get x and y, the correct formula will be:
analogWrite(11, y + int(x*seconds/60.*256));
Button Connection
The two buttons, to set hours and minutes, must be connected to the Arduino pins Db = 7 and 6 respectively, according to the schematic in this chapter. The resistor R = 1 to 5 kOhm, is needed to ground the input pins to 0 V when the button is released.
Clock Enclosure and Power Supply
Well, you can realize the clock enclosure with the material you prefer. I had a wood box with the perfect size to include the three displays. Once I drilled the rectangular holes for the displays, two holes on the back for the buttons and a socket for the power supply, I painted the wood box with a dark paint and glued everything together. In these pictures you can see the final result.
You may need to reprint the analogue display background with the suitable scales for hours, minutes, and seconds as well.
Finally you can power the Arduino with a battery or with an external power supply.
Conclusions
This is a simple project to create a cool and original clock, by means of analogue displays for voltmeters.
You can start with this Instructable and add more features, such as an alarm, for instance.
It has a steampunk looking. The older/stranger the displays, the cooler the result.