loading
This instructable will help you to build an Arduino Binary Clock.  The orignial idea for this instructable was designed by Daniel Andrade.  My instructable uses surface mount components, but can easily be adapted to through-hole components if you wish.  You can follow my other Instructable for Building Your Own Arduino to get started.

I would encourage you to give the surface mount an attempt however as this project is a great way to begin learning to solder surface mount components. 

For my clock, I have the display set on the top of the container. I use it on my workbench which I am usually standing at, so this way is easier to see.  It also creates a nice luminous effect when the lights are down low or off, casting the blue color upwards into the room.

You can select a container to your liking and place the clock face how it best fits your needs.

Step 1: Component Shopping List

Below is a list of all the items that you will need in order to complete this project.  I have tried to include places where you can order from as well as optional components that you may want to pick up.

This list is for surface mount items.  If you decide to go with through-hole components, the resources I have listed all sell them as well and you can just do a search on the component.

What You Need:
  1. ATmega168 with Arduino Bootloader - Available at FunGizmos for $4.00
  2. 10K Resistor - Available at Jameco - Cost 0.01 (ea./ 100 for $1.00) Item # 1877832
  3. 220 Ohm Resistor - Available at Jameco - Cost 0.01 (ea. / 100 for $1.00) Item # 1878149
  4. 22pF Capacitor - Available at Jameco - Cost  0.06 (ea. / 100 for $6.00) Item # 1856783
  5. 10uF Capacitor - Available at Jameco - Cost 0.12 (ea. / 10 for $1.20) Item # 1858797
  6. Pushbutton Switch - Available at Jameco - Cost  .35 ea. Item # 2076236
  7. LM78L05AC Voltage Regulator - Available at Jameco - Cost .39 ea. Item # 902186
  8. 13 LED's. I used Blue, but you can use any color. Available at Jameco - Cost .25 ea Item # 2046441
  9. 16MHz Crystal - Available at SparkFun.com - Cost 1.50 ea SKU: COM-00536
  10. DC Power Jack Connector - Available at SparkFun.com - Cost 1.25 ea. PRT-00119
  11. If you don't already have one, an Arduino Board. Available at SparkFun.com - Cost 29.95 DEV-00666 or Build Your Own Arduino
  12. PC Board (Perf Board/Proto Board) - Available at Radioshack - cost varries.
  13. Optional Protoboard - Available at Wright Hobbies - Cost 3.99 Item # PB400. I love these!
  14. Project Container. This will be used to house your clock. I went to Hobby Lobby craft store and picked up a cheap wood box for $1.99, and some scrap trim molding from Lowes for .25
  15. Translucent Acrylic - I picked up some white translucent acrylic from a local shop which cost $1 per pound.
  16. x2 SPDT Pushbuttons - Available at RadioShack -Cost $3.99 - Catalog #: 275-1549

Step 2: 8421 Binary and 24 Hour Time

First, lets take a look at how to understand the 8421 Binary system.  Your clock is going to have two columns for the "hours" and two columns for the "minutes".

We are using a 24 hour time system.

With that said, if it were 8 AM, the time is 0800 hours and if it were 8 PM, the time would be read as 20:00 hours.  In US Army basic training, when you first learn this time system, they taught us to just count backwards by 2 for PM times. So for example, if I was told to be in formation by 2100 hours. In my head I was thinking 2100 - so 1, 0, 9 and knew they meant 9 PM.

Or if we were off work  at 1630 hours, in my head I was thinking 1630 - so 6, 5, 4 and knew the day was over at 4:30 PM. I hope that makes sense, I felt the need to explain for anyone who is not use to telling time with this method.

Looking at the 8421 Binary Example image, in the first column of the hour leds, if the first led was lit up, its value would be worth 1 and in the second column if the 4th(top) led was lit, its value would be worth 8. Therefore you would have 18.

Now with the minute leds, lets say the first column has the third led and the first led lit up. This value would be 4+1=5. The second column, third led is lit up would give a value of 4. So together you would have 54.

The overall time would read as 18:54 which would be 6:54 PM

Look at the second image example. The time is 21:37


Examples Images from Daniel Andrade

Step 3: Creating the Arduino Binary Clock PCB

You have a few options with this step.  You could use your Arduino board and run all the components to it.  This option however, you wont have access to your Arduino as long as you are using the clock :(              so you would have to buy another one.

You can Build Your Own Arduino onto a piece of Protoboard, and then run the connection wires to a seperate protoboard that has the LED's on it.  This was the method that I used for my first clock design.

A better approach would be to etch your own copper PCB.  The second clock that I designed I went with this method.  There are pleanty of Instructables on how to do this.  Since this method requires more equipment, I am going to keep with the first clock design for instruction purposes. Later or on your own you can research other methods if you would like to attempt etching your own PCB.

Once you have the protoboard that will be used as your Arduino completed. Use your actual Arduino board, and upload the sketch supplied at the end of this tutorial.  Pop that chip out, and place it in the protoboard Arduino.

The resistors and leds will be connected from the second protoboard, down to your designed Arduino board. Follow the attached schematic with this step.

Arduino Pin 1 connects to Resistor 1 which connects to LED 1, which connects to GND.
Arduino Pin 2 connects to Resistor 2 which connects to LED 2, which connects to GND.
* repeat this process for all 13 resistors, pins and led's.

SOLDERING TIP.
Place a tiny and thin layer of solder onto the area that you are going to be soldering to first, then with one hand holding the soldering iron, and the other using a pair of tweezers, place the component onto the area to be soldered to. Hold it down with the tweezers, and then reheat the solder. Keep pressure applied with the tweezers and move the solder iron away. Now you can let go with the tweezers and the part will be connected into place. More Instructables for soldering.

Step 4: Clock Case

The next step is to measure out and cut the acrylic. I cut slightly over the amount of the protoboards so that I had room to move the location of the LED's around to be fairly centered.

For the clock housing, I selected a box that had a deep lid. This allowed me to be able to fit the protoboards into it, and still have room to make a flat cover to hide everything once the lid is opened.

I drew out a square pattern for where the face will be, then drilled a hole into the corner. This allowed me to use a small copping saw to then cut out the shape. The cuts are kind of rough, so I added trim molding around the opening to hide this. It also makes it look more finished.

After I sanded and stained the box, I placed the acrylic and components in and measured where the pushbuttons and power jack were located. With a drill bit and counter sink, I made the holes for them. Carefully insert your arduino binary clock boards into the lid.

Step 5: Arduino Sketch

/*
An open-source binary clock for Arduino.
Based on the code from by Rob Faludi (http://www.faludi.com)
Code under (cc) by Daniel Spillere Andrade, www.danielandrade.net
http://creativecommons.org/license/cc-gpl
*/

int second=0, minute=0, hour=0; //start the time on 00:00:00
int munit,hunit,valm=0,valh=0,ledstats,i;

void setup() { //set outputs and inputs
pinMode(1, OUTPUT);pinMode(2, OUTPUT);pinMode(3, OUTPUT);pinMode(4, OUTPUT);pinMode(5, OUTPUT);
pinMode(6, OUTPUT);pinMode(7, OUTPUT);pinMode(8, OUTPUT);pinMode(9, OUTPUT);pinMode(10, OUTPUT);
pinMode(11, OUTPUT);pinMode(12, OUTPUT);pinMode(13, OUTPUT);

pinMode(0, INPUT);
}

void loop() {

static unsigned long lastTick = 0; // set up a local variable to hold the last time we moved forward one second
// (static variables are initialized once and keep their values between function calls)
// move forward one second every 1000 milliseconds

if (millis() - lastTick >= 1000) {
 lastTick = millis();
 second++;

}

// move forward one minute every 60 seconds
 if (second >= 60) {
 minute++;
 second = 0; // reset seconds to zero
}

// move forward one hour every 60 minutes
if (minute >=60) {
 hour++;
 minute = 0; // reset minutes to zero
}

if (hour >=24) {
 hour=0;
 minute = 0; // reset minutes to zero
}

 munit = minute%10; //sets the variable munit and hunit for the unit digits
 hunit = hour%10;


 ledstats = digitalRead(0);  // read input value, for setting leds off, but keeping count
 if (ledstats == LOW) {
   
 for(i=1;i<=13;i++){
 digitalWrite(i, LOW);}
 
 } else  {

 //minutes units
 if(munit == 1 || munit == 3 || munit == 5 || munit == 7 || munit == 9) {  digitalWrite(1, HIGH);} else {  digitalWrite(1,LOW);}
 if(munit == 2 || munit == 3 || munit == 6 || munit == 7) {digitalWrite(2, HIGH);} else {digitalWrite(2,LOW);}
 if(munit == 4 || munit == 5 || munit == 6 || munit == 7) {digitalWrite(3, HIGH);} else {digitalWrite(3,LOW);}
 if(munit == 8 || munit == 9) {digitalWrite(4, HIGH);} else {digitalWrite(4,LOW);}

 //minutes
 if((minute >= 10 && minute < 20) || (minute >= 30 && minute < 40) || (minute >= 50 && minute < 60))  {digitalWrite(5, HIGH);} else {digitalWrite(5,LOW);}
 if(minute >= 20 && minute < 40)  {digitalWrite(6, HIGH);} else {digitalWrite(6,LOW);}
 if(minute >= 40 && minute < 60) {digitalWrite(7, HIGH);} else {digitalWrite(7,LOW);}

 //hour units
 if(hunit == 1 || hunit == 3 || hunit == 5 || hunit == 7 || hunit == 9) {digitalWrite(8, HIGH);} else {digitalWrite(8,LOW);}
 if(hunit == 2 || hunit == 3 || hunit == 6 || hunit == 7) {digitalWrite(9, HIGH);} else {digitalWrite(9,LOW);}
 if(hunit == 4 || hunit == 5 || hunit == 6 || hunit == 7) {digitalWrite(10, HIGH);} else {digitalWrite(10,LOW);}
 if(hunit == 8 || hunit == 9) {digitalWrite(11, HIGH);} else {digitalWrite(11,LOW);}

 //hour
 if(hour >= 10 && hour < 20)  {digitalWrite(12, HIGH);} else {digitalWrite(12,LOW);}
 if(hour >= 20 && hour < 24)  {digitalWrite(13, HIGH);} else {digitalWrite(13,LOW);}

 }

 valm = analogRead(0);    // add one minute when pressed
  if(valm<800) {
  minute++;
  second=0;
  delay(250);
 }
 
 valh = analogRead(5);    // add one hour when pressed
  if(valh<800) {
  hour++;
  second=0;
  delay(250);
 }


}
 

<p>I made this binary clock using an Arduino UNO R3. </p><p>It works except it gains about 5 minutes a day. Is there a way to adjust the sketch or something else to make the time keeping accurate?</p>
<p>why not add a bit to the code that sets it back 5 minutes every 24 hours? Should be able to do it with a bit of research</p>
<p>Instead of keeping and calculating the time in the sketch, you could use a RTC (Real Time Clock) to keep time for you...</p>
<p>This is prety cool. I got it to work but I have a question. Does anyone know what to change in the code to make it count in seconds?</p>
<p>Hello, I'm really new to arduino (this is my first one!). Anyway I was wondering that in the case that I am okay with running all the components to my arduino board even though I wont be able to use it again, how would I go about setting that up???? Thanks</p>
I have now made 2 versions of this clock, and both are having trouble with pin 7 not going high (unit 8 on the tens of minutes)...<br /> <br /> Any ideas?<br /> <br />
I have run a chase program on my arduino, and pin 7 is working fine... Help, please!<br />
lol. my parents want me to make one too, but neither of them, nor my sister understand binary. I spent half an hour explaining to them the concept of binary before showing them this clock. my sister then says &quot;so how do you read it&quot;
Don't worry, guys. I've just won the prize for being the worlds biggest f**kwit!<br /> <br /> Maybe next time, i'll learn to read a schematic. (only been doing this electronics malarkey for years)<br /> <br /> Nice job... My housemate wants me to build him one, now, even though I am knocking my head against a wall trying to explain binary to him...<br />
Glad you figured it out. I just got back from class and saw you posted. Went to the post and you already figured out :)<br /> <br /> Looks nice as a shield!<br />
<p>thanks for this</p>
What pins do the buttons connect to? i have been searching these insructions (and the daniel andre site is having issues right now :( ) so i cant find out what to do. i have an arduino uno by the way :)
Ever figure this out?
why doesnt this include instruction for how to hook up the buttons? I need to know where and how. thanks
&nbsp;This is definatly awesome! Now... it's time to do it with UV leds and&nbsp;fluorescent&nbsp;acrylic... awesome....<br /> <br /> One more question that I can't seem to find the answer to anywhere. Lets say I wanted to build this and then take the microcontroller out of the arduino and have it&nbsp;permanently&nbsp;soldered&nbsp;onto the board (or another uC with the sketch and bootloader on it)... what has to go on the board for the&nbsp;circuit&nbsp;to still run?<br />
I attached a photo to this that has everything on one board. Is this what you mean? My other Instructable at <a href="https://www.instructables.com/id/Build-Your-Own-Arduino/" rel="nofollow">https://www.instructables.com/id/Build-Your-Own-Arduino/</a> shows everything you need to make the Arduino, so you would just put this on your board and arrange everything.<br /> <br /> I added an Eagle file of just the Arduino PCB portion that I did, and Chris Mitchell emailed me for a copy and added the 16Mhz crystal and two caps rather than using the 16Mhz Resonator.<br /> <br />
Awesome I think thats exactly what I'm looking for. Keep up the awesome work.. perhaps we'll collaborate on an instructable in the future?<br />
So the time in the first picture is 14:32?<br />
Yes.<br />
this is a win. good job. 5*<br />
Thanks! I&nbsp;hope you are right :)<br />
How well does the arduino keep track of time?<br /> I&nbsp;have heard it has some problems keeping track of time, especially after several hours.<br />
the clock is getting the time by counting the millis. and then&nbsp;overflows back to 0.&nbsp;so far I havent noticed a lagg and its been running for a couple of weeks. <br /> <br />
Oh yeah, I heard of that.<br /> (And i also heard that it can only count for about 39 years! :P )<br />
I am not sure on that. But if the Maya calendar&nbsp;is correct we wont have to worry about that after 2012, lol :)<br /> <br /> I saw a project not too long ago though that mentioned they&nbsp;could count&nbsp;up to 999 years and figured after that, the people alive then could figure out an answer. I will see if I can find that link again. It might have been on the arduino playground <a href="http://www.arduino.cc">www.arduino.cc</a> <br /> <br /> Do you want me to MSG you if I find the link?<br /> <br /> The best resources I find for Arduino have come from <a href="http://www.arduino.cc">www.arduino.cc</a> as well as <a href="http://www.adafruit.com">www.adafruit.com</a>&nbsp;and the ITP Physical Computing Labs at <a href="http://itp.nyu.edu/physcomp/Intro/HomePage">http://itp.nyu.edu/physcomp/Intro/HomePage</a>
Sure if you want. ;)<br />
first of all great instructable, about to build except..<br /> what ohm resister goes with the LED's ?<br /> thx<br />
<p>Thanks grantskier. The LED resistors are 220 Ohm. You can use 220 Ohm through 560 Ohm depending on what you have laying around.</p>

About This Instructable

74,944views

124favorites

License:

More by ArduinoFun:Arduino Lilypad Interactive Passion Sensing Scarf Creating Printed Circuit Boards with a INKJET Printer Dual Motor Driver with Arduino using a SN754410NE Quad Half H-Bridge 
Add instructable to: