loading

Introduction

Binary clocks are a really cool way to show the time in a mysterious way. And to those who don’t know how to read that type of clock it’s a simple, yet effective way to boost up your nerdiness level sky high. That might just be something you'd like to do?

Yes right, I know that the binary clock isn't something new and there are some very inspirational and cool Instructables for building binary clocks already, but I couldn't help myself not to add some controllable RGB LEDs and show to you how I built my own binary clock that I like best.

You like it too? Let me help you to build the same or a similar binary clock. Trust me, it is easy! The good thing for you is that you don’t have to write any schematics or software for it. Me and a friend of mine already did that. All you need to do is to go, get some parts, hook them up together and pray for them to work right away!

---

Table of Contents

  • Introduction - The NerdClock: An RGB Binary Clock [based on Arduino]
  • Introduction - How to Read a Binary Clock
  • NerdClock - The Hardware Design I: Part List
  • NerdClock - The Hardware Design II: Schematics & How It Works
  • NerdClock - Turning Ideas into Reality!
  • NerdClock - The Final Assembly
  • NerdClock - The Arduino Software
  • NerdClock - The Acrylic Case Design
  • NerdClock - The Final Result
  • NerdClock - Extensions and Enhancements

Disclaimer: I am not responsible to anything you might do wrong with your components. The circuits are working for me and it have been tested over and over again by me but I still can't guarantee that they are free of goofs and/or errors. Note that I am neither an electrical nor a software engineer. Just a high school student fascinated by all that.

Step 1: Introduction - How to Read a Binary Clock

If you're wondering how reading the binary clock works, I will try my very best to make you understand it. Feel free to skip the part if you're familiar with them already.

Reading A Binary Clock

We are used to reading so called decimal numbers (based on the number 10). Binary clocks however use binary numbers (based on the number 2) with either '1' or '0' to code decimal representations. A switched on LED shows a '1' and the switched off ones a '0'. This type of displaying is also known as BCD (Binary Coded Decimal). So if you want to read the time, all you need to do is to translate/convert it back to the decimal number system.

Now take a look at the picture above that shows a binary clock.

There you see a binary clock divided into three sections vertically which are then divided into two columns each with the leftmost two columns representing the first and the second digit of the hour, the middle one the minutes and the rightmost the seconds. Each horizontal row represents a power of two. The bottom one shows 2^0 = 1 and the topmost 2^3 = 8.

Start off by reading the first hour digit. You can see that LED for 2 is switched off and the LED for 1 is switched on. That means you have 0 x 2^1 and 1 x 2^0 -> 0 + 1 = 1.

Continue reading the second hour digit. All LEDs are switched off. 0 x 2^3 + 0 x 2^2 + 0 x 2^1 + 0 x 2^0 = 0 + 0 + 0 + 0 = 0. So you get 10 AM.

Doing the same for the minutes will give you 2 + 1 = 3 and 4 + 2 + 1 = 7 -> 37

That's 10:37 AM.

Reading the seconds will give you 10:37:49. Practically I think it's not necessary to know the seconds, though.

Still confused? Read it again! Or maybe I'm just not good enough at explaining. So if you still don't get it, try some other really cool guides on reading the BCD clock:

http://www.wikihow.com/Read-a-Binary-Clock

http://www.exploringbinary.com/how-to-read-a-binar...

Or let a video help you: https://www.youtube.com/watch?v=IdVSTQaZGgQ

Step 2: NerdClock - the Hardware Design I: Part List

Let's dive into the technical parts of this Instructable!

Just like my previous Instructable about how to build a vacuum fluorescent display clock, I won't keep you waiting but tell you the parts you need right away if you wan't to build the clock! I tried to keep them generic as always:

    • 1x Atmel ATmega328P-PU. Purchase a standalone one or take it out of an Arduino!
    • 3x 74HC595N (THT) or 74HC595D (SMD) Shift Registers
    • 1x 28-pin DIP socket
    • 3x 16-pin DIP socket (optional)
    • 24x 5 mm RGB LEDs common cathode!! (THT) or 5050 RGB LEDs (SMT)
    • 24x 2N7000 (THT) or 2N7002 (SMT) N-Channel MOSFETs
    • 3x P-Channel MOSFETs (can be e.g. IRF9Z24N if THT and IRLML6402 if SMT.)
    • 6x Tactile switches / "push buttons"
    • 3x 10K potentiometers
    • 24x 180R resistors (red)
    • 24x 200R resistors (blue)
    • 24x 220R resistors (green)
    • 6x 10K resistors
    • 27x 1M resistors
    • 1x 16 MHz HC49U/S crystal
    • 2x 22pF ceramic capacitors

    THT means through hole technology. Good for perfboards and breadboards. SMT stands for surface mount technology, good for PCBs and devices that have limited space.

    Get a checklist below or get a programmed NerdClock kit with all the parts and an original PCB!

    All the required components should be available for around 20 euros. You can source either kind of RGB LEDs from China at dirt cheap price. The reason I've used these particular P-MOSFETs is because they had great availability in my local seller. Switches, resistors, capacitors and even crystals can be salvaged from scrap.

    The whole circuit runs off 5V DC so you can supply the power from a regular USB port. Use a linear regulator (e.g. LM7805) or a simple switcher (e.g. LM2576/2596) if your input voltage is higher than 5V. I recommend the latter regulator for a high efficiency.

    Then obviously required:

    • An Arduino Uno for prototyping and/or uploading the code to the AVR microcontroller
    • Prototyping board or PCB (Get the original NerdClock PCB here)
    • Some money
    • Measuring equipment. I find the continuity testing function most helpful when soldering components. Use it to measure voltage levels and current draws
    • Soldering equipment
    • Some wire
    • A lot of coffee, music, time and patience
    • Muuuuuuch love and passion
    • Someone to show you clock off to

    Step 3: NerdClock - the Hardware Design II: Schematics & How It Works

    Now you know which components are basically required to build such a binary clock, let me explain to you why. Only take the schematics from this part if you really don't care how it works.

    ---

    The Arduino Standalone Design

    Arduino is cool, the code simplifies a lot, and the most important thing: The simple way to upload your code just using the USB interface. We will take the programmed, debugged AVR on the Arduino out and make it standalone for our clock we built on PCB or prototyping board.

    ---

    Driving The RGB LEDs

    ... is simple and straightforward. There are three parts that make the matrix possible:

    • The Atmega328 doesn't have 24 output pins. So we use 3x 74HC595 8-bit shift registers to expand our I/O-pins that will be required to control each of the 6x4 = 24 RGB LED's cathodes.
    • Since in theory (and in actual) the current draw of each LED cathode can vary from a few mA to 60 mA, it's perfect to use a simple N-channel MOSFET that has the great characteristic of being voltage controlled, rather than being current controlled, like a BJT would be. Because we don't know when our LED will need to sink 2 mA or 60 mA. That explains the use of 24x 2N7000 small signal N-channel MOSFETs. For proper pull-down, 1M resistors need to be mounted between the source (GND) and the gate.
    • The anodes needs a positive voltage. So switching GND to them won't make any sense here. That's why we now need so called high side switching for them anodes. This can be done by P-channel MOSFETs. Anodes of the same colors will be tied together and each of the three colors will receive their own P-MOSFETs. These are driven by three of the Arduino's (AVR's) PWM pins to give each color a brightness level.

    Step 4: NerdClock - Turning Ideas Into Reality!

    Initially I planned to mount the LED matrix on and through a wooden panel and stick the panel into a picture frame glass. That would necessarily separate the controller board so that I had enough space to get the control circuit on perfboard. After I finished the perfboard, I realized that it is almost impossible to move 24 LEDs, 72 resistors and hundreds of wire pieces from the breadboard to a fixed, limited space and thus discarded the perfboard for possible future use and decided to create an actual PCB for it.

    Conclusion: I don't recommend using perfboard unless you have plenty of space and don't mind making the clock really huge. If you plan to use a perfboard anyway, the photos could give you an idea about how you gonna position the components on it.

    --------

    So instead, this time I decided to put my work on an actual PCB. To fit all the components on a rather limited space I SMDed out every THT component I've previously used on breadboard but left the AVR THT and put it on the top layer for easy swapping in case of firmware updates.


    If you want to build a PCB for home etching, avoid vias. Use jumper wires, holes or 0 ohm bridges to switch between layers instead.


    The design of my PCB is also very simple:

    • The LEDs are arranged to a matrix and put on the top side of the PCB together with the current limiting resistors of each LED (180R for red, 200R for blue and 220R for green). Green has the highest resistance because it's the brightest, by far.
    • The bottom layer of the PCB holds the rest of the control circuitry.
    • You will find the shift registers close to the LED groups and the cathode MOSFETs.

    Resources: The cleaned up schematics for the NerdClock PCB.

    Step 5: NerdClock - the Final Assembly

    In this step I assume you either decided to use perfboard or already have a PCB. We are ready to turn the components you got all together into a working NerdClock! Put the schematics next to your perfboard or PCB and begin assembling!

    ---

    Step for step assembly instructions (PDF) of the NerdClock kit -> this way! (or down below). My assembly instructions for the NerdClock kit also covers how to hand solder tiny SMD parts such as SOT-23, SOP ICs and 0603 resistors.

    So if you've never dealt with SMD before, take a look at the document. Don't do the same mistake I did, which was being afraid of small SMD components. Soldering them is fun and I basically do it with a 4€ soldering iron I bought about six years ago some 3€ desoldering pump.

    ---

    These are my general advices for soldering the components either to a PCB or to perfboard:

    Soldering everything on a PCB usually takes a few hours; perfboard soldering can take up to one week or a few days if you are fast enough. So prepare some coffee and take some patience with you. If you feel exhausted or demotivated, take a break and go for a walk. Protect your eyes. Here are some tips for you during assembly I think that might be useful to you:

    • Doesn't matter how you are going to assemble your parts into a clock, it's always helpful to begin soldering the shortest, smallest components. Tiny resistors definitely belong into this category as well as SMDs, SMD ICs and diodes. The last thing you want to do is to mount TO-220s and electrolytic capacitors. With those soldered to the board, it gets really uncomfortable if you want to change anything of smaller size.
    • [Perfboard] Remember to initially roughly locate the components and see how you can get the best possible way to connect. You want to eliminate overlapping and crossing over wires in order to reduce the jumper wires you will have to use.
    • [Perfboard] Try to solder short and thick traces in order to ensure the best possible connection. Use the continuity testing function of your multimeter regularly to check if you did everything right, even if you are mounting components on a PCB and check for leads that you have tied together accidentally.
    • Remove unwanted connections with a solder sucker.
    • Always use the continuity tester function of your multimeter to check if something is overlapping, unconnected or connected incorrectly.

    Finished? DO NOT INSERT THE ICs INTO THEIR SOCKETS YET! Check every connection twice and if you really think that everything has been mounted correctly, plug in the main power chord. Take a multimeter, check if VCC is 5V and GND is 0V. Now we will upload code to the Arduino and mount it to our clock!

    You can either directly upload the final clock software (Get the software from the next step) or use a handy assembly checker program I wrote to test if you've wired each and every LED correctly. The assembly checker automatically goes through a test routine (if not, reset the clock). It won't tell you if something's installed incorrectly, but you will see it. The sketch goes through the following tests:

    1. One of 24 R LEDs individually on
    2. One of 24 G LEDs individually on
    3. One of 24 B LEDs individually on
    4. One of 24 RGB LEDs individually on
    5. All 24 RGB LEDs on (2 seconds)
    6. All 24 RGB LEDs off (2 seconds)
    7. All 24 R LEDs on (2 seconds)
    8. All 24 G LEDs on (2 seconds)
    9. All 24 B LEDs on (2 seconds)

    The 2nd picture shows the assembly checker; the 1st picture shows the assembled clock running.

    Step 6: NerdClock - the Arduino Software

    A friend of mine did most of the awesome software work to get this clock working perfectly. One of the coolest things is that he made the code easily expandable with code you can add yourself to make the clock maybe to do things you want it to do. I cleaned up the software a little bit for more comfortable reading. You will also find all the explanations here in the code.

    You can...

    • ... manually adjust the accuracy of the clock by changing timeDivider
    • ... add more colors to let the color fader fade through by increasing colorLength and adding colors to the array int colors [][3] = {{255 - R1, 255 - G1, 255 - B1}, {255 - R2, 255 - G2, 255 - B2}, {255 - Rn, 255 - Gn, 255 - Bn}}. By default it will fade through the rainbow spectrum smoothly.
    • ... adjust the time it sits on a full color by changing colorDelay
    • ... adjust how fast the fade process will take
    • ... add more color modes (e.g. static green) by increasing ledModesNum and adding your own if conditions.

    Here's how the loop routine roughly works:

    1. Check for which LED mode it is on. Fade or manual potentiometer set?
    2. Check if any of the time set buttons is pressed
    3. Check if the user has decided to stop the clock by pressing the respective button
    4. Check if the user has decided to change the LED mode by pressing the respective button
    5. Check if a second has passed. If yes -> seconds increase by one -> redraw matrix

    Known issues:

    Inaccuracy. The clock uses the millis() function to calculate the time and that's inaccurate. The accuracy I believe depends on the clock source and varies from crystal to crystal. Mine is off by a minute every 24 hours

    Step 7: NerdClock - the Acrylic Case Design

    To make the NerdClock look complete and not-so-prototypish, I decided to give it an acrylic case. Just a basic one, no fancy design (I actually don't know how to make it fancy) that could be cut out from a 25 x 15 cm 3 mm thick transparent acrylic panel. So I sticked to a plain square design that is just large enough hold the binary clock PCB in place. The fundamental was created at MakerCase (http://www.makercase.com) I added some engraving text and the required holes. Ready for the laser cutter!

    The result is shown in the picture. I actually really like the work the laser cutter did.

    So I got my own laser cutter? Wrong guess. I've found FabLab Berlin a few streets away from where I live where makers and some creative people meet up. They got laser cutters , CNC mills, 3D printers and stuff for rental. If you want to cut an acrylic case yourself, try to find similar places or let someone else do it for you (e.g. https://www.ponoko.com).

    Resources: SVG of the acrylic case to cut and engrave yourself!

    ---

    [It'd be fantastic of you if you could vote for this Instructable in the Epilog contest. Since I got very limited time to use the laser cutter there (it's calculated as price per minute use), I always have to keep my design to the minimum to avoid super high costs as a student. So with a great laser cutter myself I could give all my projects a more fancy, unique and beautiful outward appearance. Thank you <3]

    Step 8: NerdClock - the Final Result

    Just one thing to note is that I added a tint foil to the acrylic front panel. That diffuses the super bright LEDs and not only makes it way more challenging to photograph, but also look better (personal opinion) and is more comfortable to look at when it's dark.

    Step 9: NerdClock - Extensions and Enhancements

    Finally I'd like to share an extension I made to the finished version of NerdClock for a more comfortable use. It expands the clock with a real time clock (DS1307) that increases the accuracy and keeps time of the clock even if it is not connected to a power source. For my own PCB design it means that two color setting potentiometer pins need to be sacrificed in order to make this possible because these two are connected to the I2C interface connectors of the AVR microcontroller.

    Wiring then goes like this:

    • SDA pin of AVR (pin 27) to DS1307 RTC module SDA pin
    • SCL pin of AVR (pin 28) to DS1307 RTC module SCL pin
    • VCC and GND accordingly

    I wrote the RTC extension firmware for the clock. The software removes the ability to set R, G and B manually but adds RTC.

    <p>looks very cool although i guess it could be done with less effort if ws2812 or similar LEDs were used.</p>
    Wouw, costs a lot of effort to read! Tho it is very cool. How did you manage to design the circuit?
    <p>Thank you a lot! Then I will review my Instructable again and see if I can remove unnecessary parts.</p><p>The circuit was designed from scratch. I already used parts of the circuit in earlier, similar projects so it works reliably :-D</p>

    About This Instructable

    5,507views

    117favorites

    License:

    Bio: I love cranberry chocolate cookies and VICTORiOUS :3 Electrical engineering for fun - CPU Museum founder - http://cpumuseum.jimdo.com/
    More by Kesselwagen:The NerdClock: An RGB Binary Clock [Arduino Software] Arduino VFD Display Clock Tutorial - A Guide To VFD Displays 
    Add instructable to: