This is a simple clock that shows the time (hours/minutes) in binary using leds hidden beneath glass marbles.

For an average person it looks just like a bunch of lights, but you will be able to tell the time by just a quick glance at this clock. It might take you a couple of days to get up to speed on the esoteric art of fast binary counting, but you'll be able to tell the time right away, just a bit slower in the beginning.

Here's a instructable of counting in binary Binary counting.

Step 1: What you need

  • One Atmel Tiny2313 microcontroller
  • One 0.1 uF capacitor
  • Eleven resistors - 120 ohm
  • Eleven high brightness leds. I used 6 white and 5 yellow
  • One 10 MHz crystal
  • Two 20 pF capacitors
  • One small pushbutton
  • Eleven glass marbles
  • A nice piece of wood to mount it all on

The picture below are missing the leds and resistors...
This is cool! I'm gonna make one. Btw, just wondering where do you normally source for parts? Around KL/PJ or online?<br>P/S: Are you by any chance the same guy who came up with that QuaterK shield? Love that too :)
Sometime I go to Jalan Pasar in the Pudu area, but usually I just order from Farnell/Element14. They have free next day delivery so it's quite convenient.<br><br>Since I travel to Bangkok twice a month I get a lot of stuff from the shops in the Ban Mo area there. I get standard components in bulk from there like 1000 packs of 0.1uF decoupling caps.<br><br>For the 200 QuarterK kits I did a while ago I got almost everything from the Chinese merchants on Taobao.com. The prices there is less than 50% than the already cheap Ban Mo-prices. But you have to wait for the shipping a bit longer and also use a shipping agent that will repack your stuff and send it to you since the merchants don't ship overseas and usually don't understand English. <br><br>/mats
hey mat,. gr8 proyect. i cant get it to work though. tried several times. bottom line: what do i do with the control fuses? is my chip fried? -----&gt; I'm down to 2 conclusions: either my Tinys have static damage. or the fuses are wrong and its using the internal oscillator and not the crystal. furthermore it might be dividing the frecuency internally, apparently there is a clkdiv8 fuse or something. Please help ! my girl's BDay looms inexorably closer--&gt;Symptoms: 1)i have the 20 MHZ. (actually ive done this with 3 chips already, maybe one was 10 MHZ, which didnt work either)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2)the Attrac() &quot;nightrider&quot; mode runs at about 1/2 htz&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3)once i press the button and reset to 12 o clock it doesnt advance( maybe it's waaaaay slower and i dont stick around long&nbsp;enough).&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;4) when i press button, it doesnt update LEDS until i release it changing time to a random time and u have to press for more then 3 seconds for it to do anything at all&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; . 5) i yank the crstal and it keeps doing the nightrider thing.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;again Please help.
ok, i've fixed it, yeah!! finally! ---&gt; the Tiny ships with the clkdiv8 fuse programmed ( meaning its &quot;0&quot; ) it also ships with de clksel fuses[3,2,1,0] = 0100 meaning it using the internal 8 mhz oscillator and not the crystal. which gives 1 mhz clock ( ten times slower then should be), you can verify this by letting your clock run for ten minutes and see one minute increment, ten hours and see 1 hor increment. Solution= change CLKDIV8 to &quot;1&quot; ( off) and change CLKSEL to &quot;1111&quot;. and voila !! and yes PB4 is pin 16 ( not pin17) and yes, it is military time ( aka : 21 hours for 9 pm). note: fuses are not modified when you programm the chip you have to modify them yourself in the programmer... (look for the device config tab or something) ok now i can say it Excellent job MatSeng! best one yet!
Hi!<br /> <br /> Very nice instructable! I've built the clock, but I had no 10 MHz crystal so i used a 20 MHz one instead. I've been fiddling around with the code to compensate for this but have, so far, been unsuccessful. Without changes to the code one minute on the clock equals exactly 10 minutes in reality. What parameters should i change to make it run correctly?<br />
Why do you have 5 hour lights instead of 4?&nbsp; Are you doing military time, 24 hours rather than 12?<br /><br />Very nice clock, BTW.&nbsp; I want to do something similar as a watch, but I can't find the chip already programmed for a reasonable price, and I don't want to invest in the equipment to do it myself for a single project.<br />
I finished my clock, but it runs way to slow! i made the time 23:29 last night and then went to sleep. at about 09:45 the clock said it was just after midnight! what is wrong?
i got it working, i did the math, rewrote line 65 into <br/>ticks-=169756,4444444444444444444444444443;<br/>and now it works pretty exact, still got to find out how exact over a week, going to try that now :)<br/>
u need to change ur handdrawn diagram,it says pin17 controls H16, but in the code it says pin16 controls H16, and its kinda odd to skip a led. also, how can i make the time improvement of the button go faster and the minus 1 minute go earlyer? its now bout 5 seconds for a minute (after that 15 second speed increase) and half a second for decrease of minute. i would like something that goes 1 minute increase every second after the speed increase, and 1 minute increase every 2 seconds before, and right after i push i should be able to release for a decrease of 1 minute. how do i alter the code? il upload some pictures in a slideshow when i get it all done, now its kind of messy with the wiring... also, i used a protoboard and a socket for the IC, seemed handyer to me.
you need to change ur handdrawn diagram,it says pin17 controls H16, but in the code it says pin16 controls H16, and its kinda odd to skip a led. also, how can I make the time improvement of the button go faster and the minus 1 minute go earlier? its now bout 5 seconds for a minute (after that 15 second speed increase) and half a second for decrease of minute. i would like something that goes 1 minute increase every second after the speed increase, and 1 minute increase every 2 seconds before, and right after i push i should be able to release for a decrease of 1 minute. how do i alter the code? il upload some pictures in a slideshow when i get it all done, now its kind of messy with the wiring... also, i used a protoboard and a socket for the IC, seemed handyer to me.
is there anyway you could help me figure out how to do this out of an old alarm clock? it uses an mm5387AA "controller" i guess its called... this clock is pretty old, at least 15 years or so, so i figured it may be easier to use this controller...
1000=1<br/>0100=2<br/>1100=3<br/>0010=4<br/>1010=5<br/>0110=6<br/>1110=7<br/>0001=8<br/>1001=9<br/>0101=10<br/>1101=11<br/>0011=12<br/>How do you tell minutes? I think I did the binary right.<br/>Never mind, I saw more than 4 marbles on a different step. That is a very good idea, but I don't have time to make one now. Do people sell these? I can picture a computer teacher buying one, or me if they were not very expensive. I am going to favorite this.<br/>
you can buy them on thinkgeek.com i think, but i know you can buy wrist watch versions
Flip all of the binary numbers around. You read it from right to left.
Thanks! I guess my Dad taught me wrong. Oh well, I got the basic concept.
A micro-controller? Bah. That's cheating my friend. There's no challenge in that ;) Although I have to admit that this is a good implementation...
are there any screensavers that do this?
Can you explain the time algorithm in more detail. I really don't understand it.
How do you get the leds to change. Do you use a +1 to the port since it runs on binary already. like PORTD = minute <br/>minute equals 0111010 which shows which pins are high<br/>
this is really cool, is there any way to get a pre-programmed chip, and what is the power supply on this?
and how are u going to connect the ic to the computer?
You program it once through a usb programmer, and then you soldier everything together. Once you've decided to do this, you wo'nt be getting your chip back... Unless of course you soldier everything to a socket and then put the chip into that. It would also lower the chances of damage to the chip during soldiering. And easier way to do this without a Microcontroller is to use a 555 timer set to pulse once a second hooked up to some 7490 chips that divide the pulses and do the same thing as this. Then, if you only use one chip with 4 outputs, you can hook it up to a 4 line to 10 line demultiplexer such as the 7442 IC to drive a single digit nixie clock. That's what I did... And no MCU...
Accuracy? How accurate is the clock? Arduino code to keep real time usually drifts by several seconds an hour. Does yours do better? PS: I like the use of Bresenham for the ticker.
My clock not work, go only with pressed button. What is wrong? Please help!
I'm so close to being done, but each time I try to upload the source code to the chip I get errors talking about undefined variables and multiple definitions. Can someone please help, I was able to figure out how to use a atmega168 AVR and I bought a Arduino Diecimila so I could hook it up to my computer. But no luck and I even tried the ghetto programming enviro but I can't get that to work either can someone please help me.....
Hi Mats, I've got the 20MHz version of the ATtiny2313. I assume I have to change all of the "10000000" references to 20000000, right? Do I have to touch the 1638.4 uS timer0 interrupt or will that take care of itself if the program know what speed it's running at?
WOW! This instructable is just great! Thank you for doing it. I was scaning the Internet for some good DIY binary clock, and your's was the best! One question though, i can not find a 20pF cap any where, not even doble the amount of 10pF ones to conect in paralel, can i use a bit diffenet value, or it is critical? Thanks. And once more- a great instructable!
I managed to found 22pF caps, hope that it will be close enoght. Built the thing,it started flashing,but i had just set the time, i discowered, taht the clock is not ticking! Whay it is so, can anyone tell me? What could cause it? i would really apriciate any help, i have run aout of ideas, tried reprograming the uC, changing uC, checkin for shorts..
I absolutely enjoyed this instructable! I am trying to replicate this right now. I am curious as to how hard would it be to add a seconds counter to this schematic? I've seen a binary clock made out of an old harddrive, and it had seconds on it. I think the seconds are a really fun part while watching a binary clock. Great job
Thank you. Seconds would probably really enhance the looks of the clock. Unfortunately there are not enough ports on the Tiny2313 to do that using direct drive. But by adding three transistors and multiplex the hours, minutes and seconds it'd be a piece of cake. By adding three transistors, six leds and removing five resistors and adding a few lines of code. If you're interested I can draw you a new schematic and update the software...
I would be really interested in this I have an AT Mega just waiting for something to be done with it. I'm going to make this clock but having seconds would be amazing
I tell you what, if you send me the schematic and updated code, I'll build it and send you a pretty picture. Seconds would just be awesome.
Thanks for the project, quite informative. However, please forgive the ignorance, how do pass the C code you provided to the chip?
You need a programmer. <a rel="nofollow" href="http://www.instructables.com/id/Ghetto-Programming%3a-Getting-started-with-AVR-micro/?ALLSTEPS">This instructable</a> has a nice description of a DAPA cable, which uses a parallel port. You can also make a DASA or ponyser cable, all of which can be found with a little googling or <a rel="nofollow" href="http://www.olimex.com/dev/pdf/avr-pg1b.pdf">here</a>. These are all in the class of bitbang programmers. If you want more professional porgrammers, you can consider a USBtinyISP, made by <a rel="nofollow" href="http://www.adafruit.com/index.php?main_page=product_info&cPath=16&products_id=46">Adafruit Industries</a><br/>
OOPS! I forgot the most important thing! You need WinAVR to compile and burn the code. It includes programmer's notepad and avrdude to do all this. <a rel="nofollow" href="http://winavr.sourceforge.net">LINK.</a><br/><br/>(This is for the windows platform. I am not sure if they have done a mac or linux port yet.) <br/>
Wow I've always wanted a binary clock but I couldn't find them anywhere except for the internet. So now I can just make one Instead.
is there any way i could do this with a basic stamp or pic microcontroller
I like this a LOT. Shame I don't have the resources to program the chip.
CLOX - instruments of the devil.... It's funny tho that when you get yunga people, raised on digial clox, how they have to LEARN how to read analogue clox. Binary? Good stuff... perpetual mind expansion is important.
Nice instructable ive been looking for a good write up like this. My only question is if i had a different valued crystal like a 1MHz or so how would i modify the programming code to make the clock run properly off that so its not all off-kilter as I have plenty 1MHz crystals handy.
Oh... A 1 MHz crystal. I haven't seen those in years...<br/><br/>I think that the easiest way to tweak the code for that would be like this:<br/><br/>On the top of the code change the F_CPU define to:<br/><pre>#define F_CPU 1000000UL</pre><br/>Then change the entire ISR code to this:<br/><pre>//// This Interupt Serivce Routine gets called every 16.384 mS by timer 0//ISR (SIG_OVERFLOW0) { static int32_t ticks = 0;static int8_t ms100ticks = 0; // Standard Bresenhams time-keeping algorithm ticks-=16384; if (ticks&lt;0) { ticks+=10000000; // Increment time by 10 seconds second+=10; if (second&gt;=60) { second=0; minute++; if (minute&gt;=60) { minute=0; hour++; if (hour&gt;=24) { hour=0; } } } } // If this ISR been executed 6 times (approx 100mS) // then increment the 100mS-counter ms100ticks++; if (ms100ticks&gt;6) { ms100ticks=0; ms100++; }}</pre><br/>I think that should fix it. <br/><br/>Since your crystals are 10 times slower than the one I used then we just update the seconds by ten instead of one. The seconds doesn't get displayed on the clock anyway it doesn't matter that we step it.<br/><br/>The counter that keeps track of the 100mS timings (used by determining the length of the button presses) was previously incremented 61 times at fast interrupt rate of 1.6384 mS (61*1.6384 is approx 100 mS). Now the interrupt rate is slower, (16.386 mS) so we only need to count 6 of them to get out 100mS. There's no need for any absolute precision here since it's only used for the button.<br/>
Great instructable and fantastic pics! I especially like your "squished bug" soldering job!
Thank you. It's rather easy to get decent pictures with a Nikon D300 and some nice glass. But I really need to get my act together and finalize my homemade light tent to get a better lightning on the pictures.
To push further minimalism you could turn on quickly one LED at a time (multiplex) and thus use one single resistor shared by all LEDs on their common cathodes. The source code is well commented also. +1 Ciao
Thanks. Yes, I was thinking about that but the leds I got at hand was rather old and not that bright and the multiplexing would reduce the brightness even further. But with good leds the muxed single resistor version would probably work just fine. To really minimize the hardware I could have used a 8 pin microcontroller like PIC 12F629/675 and chalieplexed the 11 leds. 2 pins power, 4 for the leds, 1 for the button and 1 spare. The problem with that would be that I had to rely on the internal oscillator and that may case the clock to drift up to 10 minutes a day....
awesome piece. please tell us how many amps this thing needs (i have loads of old wall warts that i'd like to use, but they vary in current rating). thanks!!
With all leds on I measured a power consumption of 102 mA. The wart can be of any amperage as longs as it's larger than 100 mA<br/><br/>Just make sure that your wart is DC output and is of a maximum of 6 volts.<br/><br/>If unsure use the <a rel="nofollow" href="http://www.instructables.com/id/5V-breadboard-mini-PSU/">5 volt regulator</a> I wrote about further down in the comments to fix the power from your wart.<br/>
Does anyone have a good, cheap online source for the atmel microcontrollers? I've been wanting to get into these - I'm getting a little sick of my basic stamp kit.
I like <a rel="nofollow" href="http://www.sparkfun.com/">sparkfun</a> - they have a lot of atmel chips and accys at decent prices. I also can't recommend the <a rel="nofollow" href="http://www.instructables.com/id/Ghetto-Programming%3a-Getting-started-with-AVR-micro/">ghetto dev kit</a> highly enough - worked great for me!<br/>

About This Instructable


125 favorites


Bio: Swedish expat living now living in Malaysia after spending some years working in Dubai.
More by matseng: The Motorized Led Bolas Of Doom Binary Marble Clock Spooky Led Lamp
Add instructable to: