Introduction: Arduino Binary Clock - 3D Printed
I've been looking at Binary clocks for some time for my office desk, however they're quite expensive and / or don't have a huge amount of features. So I decided I would make one instead. One point to consider when making a clock, Arduino / Atmega328 isn't very accurate over larger periods of time (some people have seen more than 5 minutes of error in 24 hours) so for this project we'll use an RTC (Real Time Clock) Module to keep the time. These also have an added bonus that they have their own back up battery so the time won't be lost in case of power failure. I opted for the DS3231 module as its acurate to 1 minute per year but you could also use a DS1307 but its not as accurate. Obviously you don't need to use all these features, you could just make the basic binary clock and save maybe £10 - to £12 in the process. I went for a 12 hour clock format to keep the size down and to reduced LED counts and it's easier to read too. (Common sense is all you usually need to work out if its AM or PM!!)
1 x Arduino Nano (one of the cheap ebay one's) - Approx £3
1 x RTC Module (i2C) - Approx £3
1x RHT03 Temperature / humidity sensor - Approx £4
1x 0.96" OLED Screen Module (i2C) - Approx £5
11 x Blue straw hat LED's - Approx £2
11 x 470Ohm resistor - Approx £1
1 x 10KOhm Resistor - Approx £0.30
1 x 3D printed housing - Approx £12
plus a small amount of strip board and solder
Total Build cost = £30
Step 1: Build the LED Modules
The LED modules are made up of 3 or 4 LED's which have the positive legs connected together and the negative legs connected to a 470Ohm resistor. This resistor limits the current through LED to about 5mA. The maximum number of LED's that can be on at any time is 8, so the maximum current draw on the Arduino is about 40mA in and 40mA out so 80mA total - well within the comfort region of the arduino.
Fly leads are then soldered on and the resistors covered with heat shrink tubes.
Step 2: Binary Clock CIrcuit
The hub of this project is the Arduino Nano. We're going to use most of it's pins here. The RTC module and Screen are both on the i2C bus so they can share all connections. Simple connect the 5v, 0v, SDA and SCL connections to both modules (I daisy chained mine to keep the wiring down). SDA is then connected to pin A4 on the arduino and SCL is connected to Pin A5.
Next connect the RHT03 (DHT22). again this was daisy chained for 5v and 0v connections but pin 2 was directly connected back to the Arduino pin D12. Don't forget to add the 10KOhm resistor between 5V and the signal connection as shown in the diagram.
Next connect the LED modules. The power for each module is connected to Pins 9, 10 or 11 (It doesn't matter which as they are only providing a PWM signal to adjust LED brightness).
Connect the negative side of each LED to the corresponding pins in the diagram.
Step 3: Design and Print the Housing
First of all measure all of your modules so that you have mounting positions and opening sizes worked out.
I used DesignSpark Mechanical 3D CAD software to create my clock and base but you could also use any good 3D software. DesignSpark Mechanical is free to download and use and there are lots of tutorials on how to do things. Another free 3D software is SketchUp, again it has lots of online tutorials so pretty much every task is covered.
In the end you need to have an output file which is in the .STL format so that it can be printed. I've include my files for ease.
If you're not lucky enough to own a 3D printer then you can get 3D prints done via the internet. There are quite a few online printers available with very reasonable rates. I used a website called 3Dhubs and it cost just under £15 to get both parts printed.
I had both parts printed in technical ABS as the shrinkage rate is very small compared to other materials.
Once back from the printers you'll need to clean the parts up and a light sanding maybe required. I also gave mine a light coat of spray paint, but I wanted to keep the "printed" look, so I didn't go too hard on the sanding.
Step 4: Assembly
Simply fit all the modules / circuit into the cleaned up printed housing. A small amount of glue is required to bond them in place onto the internal locator pins. A small amount of glue was also used to bond the LED modules in place. (yes that is blue tack you can see in the picture. I used it hold the modules whilst the glue was setting)
Don't forget to fit the battery onto the RTC module during fitting
Then push the Arduino into position so that the mini USB port is just poking through the back of the clock.
Finally fit the base and screw into position (Make sure to have good hole sizes for the screws so they don't bite into the plastic too much as it will fracture easily)
Step 5: Power Up and Setting the Time
Before powering up you'll need to get hold of some Arduino libraries to make this work.
OLED Screen Library (you may also need the adafruit GFX library)
you can find lots of online tutorials on how to add these libraries so I won't go into it here.
The clock takes its power from the Mini USB port on the back. Simply connect this to your computer and open the Arduino Sketch 'Binary_Clock_Set.ino'
This sketch will take the current date and time set on the PC at the time the sketch compiles and load it to the clock in the setup loop. Upload this to the clock and the time will be set. Without disconnecting the clock (so the setup loop isn't started again), open the other Arduino sketch 'Binary_Clock.ino' and load it to the clock. This is the normal running sketch
If the power (usb) is lost between these 2 steps then you'll need to repeat both as the time will be incorrect.
The sketch 'Binary_Clock_Set.ino' is now only required if the clock needs to be set again i.e Daylight saving etc