# BCD Clock

## What witchcraft is this?

To answer the question, this is a CLOCK (as the heading so pointedly suggests, we'll get to BCD later). It is meant to tell the current time (from your system clock, in your timezone; if you care about that stuff). Fret not, once you understand the working of it all, this will seem little more than childs play to you!

## Well, how does it work then?

Quite simple really, it tells time in military format (ie the 24-hour format). The first 2 columns (from your left) indicate hours, next 2 indicate minutes and final 2 show the seconds. Check it out, the last column will be updated on an every-second interval.

## But there are no numbers, how to tell the time?

Using a little math, I'd say; each digit of the time HH:MM:SS is encoded into its equivalent binary format (hence the name BCD, which stands for 'Binary Coded Decimal'). For example let's say the current time is 2:30 pm which in 24-hour format is 14:30 hours, thus the binary equivalent of each digit is '0001' '0100' : '0011' '0000' (imagine the same for seconds)

This binary format is represented by the positional indicators in each column. Extending our previous example, to represent 2 pm or 14 hours or the binary '0001' '0100', our clock's hour section (first 2 columns from left, in case you forget) will glow accordingly. For '0001', first 3 indicators (from top) will be off, last one will be ON. For '0100', only 2nd indicator will be ON.

## I still don't understand how to tell time!

Well, since you've come so far, it'll let you in on the secret. Imagine a number in each block/indicator - First row indicators will have number 8, next row 4, next 2 and finally 1. Something like this :

```        | 8 | 8 | 8 | 8 | 8 | 8 |
| 4 | 4 | 4 | 4 | 4 | 4 |
| 2 | 2 | 2 | 2 | 2 | 2 |
| 1 | 1 | 1 | 1 | 1 | 1 |
```
Now, let us assume some of the indicators are ON, like those marked by X below :
```        | 8 | 8 | 8 | 8 | 8 | 8 |
| 4 | X | 4 | 4 | X | 4 |
| 2 | 2 | X | 2 | 2 | X |
| X | 1 | X | 1 | 1 | 1 |
```
Simply calculate the sum of ON indicators for each column, like this :
```        | 8 | 8 | 8 | 8 | 8 | 8 |
| 4 | X | 4 | 4 | X | 4 |
| 2 | 2 | X | 2 | 2 | X |
| X | 1 | X | 1 | 1 | 1 |
1   4   3   0   4   2
```
Well, there you have it, the time is 14:30:42 ie 2:30 pm (and 42 seconds!)

## Interesting! Where can I learn more?

I have learned about and created this BCD Clock out of pure curiosity; took me a few hours to read & code it out. My point - this is not meant to be a one stop shop for all things BCDC. In fact, most representations of a BCD Clock skip the unneeded indicators (like indicators of 4 & 8 for hours). There are also different types of binary clocks; who knows, you may come up with an innovative representation all on your own!

Here are a few public domain links that might help point in proper direction -

Wanna see how this clock works behind the scene? See javascript code here
Say hi, drop a mail at [email protected]