To begin the explanation, I would like to say that I have always wanted time to be metric. 5 o'clock would be mid-day, 7:5 would be three quarters (6:00 pm), and so on. This prototype tells deci-days, centi-days, and milli-days, in that order. For those that are unfamiliar, ten deci-days are in a day, ten centi-days are in a deci-day, and ten milli-days are in a centi-day. For comparison, a milli-day is 86.4 seconds.
With my limited supplies, I had to make it read in binary, but that's alright with me!
I am a beginner at Arduino. And a beginner at instructables. So at times it may not be perfect, and I hope you have some understanding!
Step 1: Supplies
12 leds. It helps if 8 are one color, and 4 are another, but that isn't all that important.
12 330 ohm resistors. 10k works too, but it makes the leds a bit dim.
An Arduino I have an Uno r3, but anything with 12 or more output pins will work.
A breadboard You could probably survive without one, but I would highly recommend one.
Step 2: Building It
Step 3: Code & Explanation
int deci = 0, centi = 0, milli = 0, micro = 0;
These are the variables that keep track of the time. 0, 0, 0, 0 means midnight. These should be set to the time when you upload the code, or power it on for the first time.
void setup ()
This code is fairly self explanatory. I could have used a loop or something, but I chose not to.
void writebin(int value, int pin1, int pin2, int pin3, int pin4)
This is a function function that takes a value, int value, and writes it in binary to pin1 - pin4.
if (value == 0)
if (value == 1)
These are just two out of ten if statements regarding how to write each number in binary. I won't share the rest, but they are included in the complete source.
void loop ()
writebin(deci, 5, 4, 3, 2);
writebin(centi, 9, 8, 7, 6);
writebin(milli, 13, 12, 11, 10);
These write the different variable to their respecitve pins.
This is length (in milliseconds) of one micro-day.
Indecates that a micro-day has gone by.
if (micro == 1000)
micro = 0;
This if-statement adds one to milli if micro reaches 1000, showing that there are 1000 micro-days in a milli-day.
if (milli == 10)
milli = 0;
This simple if-statement increases centi by one if milli reaches ten. It then sets milli back at 0.
if (centi == 10)
centi = 0;
Works in a similar manner.
if (deci == 10)
deci = 0;
Again works in a similar manner.
You're done with the code! Pretty simple, right?
Step 4: Determine Metric Time, From Regular Time
1. Find how many hours have gone by since mid-night. At 6:00 am it is six, at noon it is 12, at 6:00 pm it is 18, at 5:30 pm it is17.5 and so on.
2. Divide by 24. For example, at 6:00 pm, 18 hours has gone by. 18/24 = 0.75
3. You are now on the easiest step. The tenths place (in this case 7) is the amount of deci-days. The hundredth place is the centi-days, and so on. So at 6:00 pm, it is 7:5:0 in metric.
Step 5: Your Finished Product
In the future, I do plan on making some adjustments. I believe a better way to set it would be nice, seven-segment displays would be nice, and many other improvements could be necessary. But until then, I hope you have fun with your new clock!