I have provided Arduino sourcecode, and a discussion of the programming, for an electronic clock which is based upon the swings of a pendulum.
The whole exercise is just "for fun", and for various programming matters illustrated along the way.
This page is an "appendix" to that tutorial. It is a "User's Guide" for the clock, in hopes that it will help readers of the tutorial be clear about what the clock is supposed to do, so that when they are studying the sourcecode some puzzles are less perplexing.
Displays a time of day... hh:mm, which goes forward according to how many pulses come in from a source of regular pulses, e.g. a pendulum.
Alternatively, the display can show how many pulses there have been. As with the time-of-day display, this would be four digits.
And then there are two displays which indicate that you have entered the mode which lets you change the clock's idea of the time, as to hours, or as to minutes. In these modes, only two digits appear on the display.
Which you see is selected by turning a knob.
When in hh or mm setting mode, there are buttons to change the time displayed- one to increase the number, one to decrease it.
We'll get to "everyday" matters in a moment. First, a few notes about setting the clock up.
You need power. The cable with the USB connector on it should be plugged into a source of 5v. No data passes over the cable.
You need a source of 5v pulses, to regulate the clock. Two wires come from the clock, one (the black one) to go the ground of the other circuits, the other to go to the output from the other circuits.
Alternatively, connect the two wires to the clock's ground, if you are just doing tests. One of the buttons will be treated as if it were the source of the time regulating pulses.
------
Some changes will need to be made in the code, on the
if ((ulPulsesFrmPendulum % xx)==0){IncAMinute();};
lines, if your pendulum isn't exactly as long as mine is.
As mentioned: There are four display modes. (No pulses are "lost", by the way, in the course of making changes to the display mode, or in the course of changing the hh or mm settings.)
There is a knob which you turn to change the display mode.
Turn it far enough to the left, and the clock will go into the "Count of pulses" display mode.
Turn it far enough to the right, and the clock will go into its "Set Minutes" mode. The two right hand digits will show something, the two on the left will be dark, not showing anything.
Turn the knob back (to the left) a little from what is far enough to cause the "Set Minutes" mode, and the clock will enter the "Set Hours" mode. The two left hand digits will show something, the two on the right will be dark.
Those are the four display modes. To recap, if you start with the knob turned fully to the left, you will pass through the display modes in the following order... but keep reading before you try it!...
Now... and there is a reason, and you should be able to overcome the slight oddness... here is the thing I wanted you to read before you tried the knob:
The display mode doesn't always change "instantly". Turn the knob a bit... and then wait for a pulse to pass. If the display mode hasn't changed, turn the knob a bit more, and wait again. If it changes... but goes, say, from display mode 0 to display mode 2, but you wanted 1... turn the knob back about half as far as you turned it to get 2, and wait for a pulse to pass.
The knob is attached to a simple potentiometer. If there was an index mark on the knob, and numbers in a circle around it, the "right place" for a given display mode will always be with the index opposite the number it had to be opposite last time.
"Count of pulses" display mode: Four digits. The device displays how many pulses have arrived since it last started up. In this mode, four digits are always lit up, so sometimes there are some "leading zeros", e.g. a dozen is show with "0012". The four digits, and the fact that the number changes with each pulse, tells you that you are on the "Count of pulses" display mode. (At the 10,000th pulse, the display goes from 9999 to 0000, and after that, counts up again.)
"Time of day" display mode: Four digits. hh and mm. It should be easy to have the colon on, but for the moment that's being difficult. You can distinguish this display mode from the pulse count by the slower changing of the numbers. (And of course, the rollover at 59 and 23... but who wants to wait to see one of those!)
"Set Hours" display mode: See "Set Minutes"
"Set Minutes" display mode: When in "Set Hours" or "Set Minutes", the device's current idea of the hours or minutes part of the time is on display. Press and hold either the "up" button or the "down" button. Just after each pulse arrives from the pendulum, the setting will go up or down, as appropriate. (It takes a little getting used to, but as there is an up and a down button, it really isn't too tiresome.)
The system continues to count pulses regardless of what display mode you have in action at any time.
If you are counting pulses from something, i.e. you do not have the two wires tied to ground, then pressing the "fake pulse" button does what you would expect.
That button will also work if you have the wires connected to a source of pulses. But it will add "extra" counts to what is recorded, if you do press it.
If you visit 1&1's site from here, it helps me. They host my website, and I wouldn't put this link up for them if I wasn't happy with their service.
Click here to visit editor's Sheepdog Software (tm) freeware, shareware pages.. Material on this page © TK Boyd 12/18
Click here to visit the homepage of my biggest site.
Click here to visit the homepage of Sheepdogsoftware.co.uk. Apologies if the "?FrmAht" I added to that link causes your browser problems. Please let me know, if so?
Page tested for compliance with INDUSTRY (not MS-only) standards, using the free, publicly accessible validator at validator.w3.org
....... P a g e . . . E n d s .....