Introduction: Binary Metric Clock; Easy Arduino Project.

About: I am a human being that enjoys to build things. I also say GNU/Linux instead of just Linux. Yeah, I'm that kind of person.

This is a very odd kind of clock, which can easily be made with simple supplies.
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!

A note:
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

Here is a list of what you'll need (not very much):
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.
14 Wires

Step 2: Building It

The set up is pretty easy. If you take a look at the picture (created using Fritzing), the blue lines are wires, red things are leds, and the resistors are 330 ohm resistors. It is remotely self-explanatory.

Step 3: Code & Explanation

The complete code is available as binarymetricclock.ino. I will now proceed to explain the code:

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 ()
{
  pinMode(13, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(2, OUTPUT);
}

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)
  {
    digitalWrite(pin1, LOW);
    digitalWrite(pin2, LOW);
    digitalWrite(pin3, LOW);
    digitalWrite(pin4, LOW);
  }

  if (value == 1)
  {
    digitalWrite(pin1, HIGH);
    digitalWrite(pin2, LOW);
    digitalWrite(pin3, LOW);
    digitalWrite(pin4, LOW);
  }


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.

delay(86.4);

This is length (in milliseconds) of one micro-day.

micro++;

Indecates that a micro-day has gone by.

if (micro == 1000)
  {
    milli++;
    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)
  {
    centi++;
    milli = 0;
  }

This simple if-statement increases centi by one if milli reaches ten. It then sets milli back at 0.

if (centi == 10)
  {
    deci++;
    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

This step is fairly simple. There are many ways to do this, I will just share my favorite.
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

By now you've probably figured out that you're done! Your glorious new piece of time-telling equipment will greatly help you figure out how much of the day has gone by, and how much is left. Although currently no societies use a metric clock,  one can still find many ways to use this device.

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!

Arduino Challenge

Participated in the
Arduino Challenge