Pure Binary LED Wall Clock With Arduino
by ravijag in Circuits > Arduino
2191 Views, 12 Favorites, 0 Comments
Pure Binary LED Wall Clock With Arduino
My binary wall clock is inspired from many binary clocks i found on Instructables
Links:
Lilypad Arduino clock :https://www.instructables.com/id/LilyPad-Arduino-Bi...
Binary clock: https://www.instructables.com/id/Arduino-LEDs-Binar...
Plus some other binary clock instructables.
But...
What i found lacking in them was the scale and size of the display. Most were using single LEDs and i wanted something bigger and brighter as an eye catcher in the living room. I found one large scale project but lacked details other than the picture. Link :https://www.instructables.com/id/Wall-Binary-Clock-...
Choosing the Display Base
I always had wanted a large size display and wanted it to be eye catching. A quick stop at my local photo frame making shop in my locality (Sri Lakshmi frame works in Gauravnagar, Bangalore) and discussing with the owner threw up options available : thick cardboard (not the one used for carton boxes), plywood sheet, acrylic etc. Since i wanted this to be a prototype and later if needed, i could plan for an upgrade, i asked him to cut me a 12 in x 18 in Hard cardboard piece. Cost Rs 20 :). This material is typically used for backing the photo frames here. The shopkeeper assured me that there would be no issues mounting the final board into a framed structure if needed, provided i have an allowance of 1 inch on border.
Took home the cardboard, worked on it as a template and put some rough sketching on where to place the LEDs. You can use your school geometry skills to draw lines and finalize the LED placement points. I chose a diamond template instead of a square (as that won majority vote 2:1 in my family of 3)
I wanted a pure binary clock and not a BCD one to limit number of pins plus avoid too much soldering. Most clocks i saw on instructables lacked the seconds feature which was most important for my instructable :). So i needed 6 lines for Seconds, 6 for minutes and 4 for hours, totalling 16 lines in all to drive the clock. Since i had some components at hand (wanted to minimize the visit to electronics shops in SP road where the entire bangalore runs to for buying anything and everything related to electronics-discrete components and all), i chose an arduino promini as processor and reused the code from this instructable with minor modifications to the code to accommodate the pin availability on my board ( https://www.instructables.com/id/LilyPad-Arduino-Bi... Will share the code later.
Choosing the LEDs:
I had some LEDs which i had bought long back to build a LED Cube for an Arduino project but not done for lack of time. I chose While LEDs for seconds, Blue LEDs for minutes and Red LEDs for hours
White: 6 bitsx 4 LEDs per bit=24 LEDs
Blue: Same = 24 LEDs
RED: 4 bits x 4 LEDs per bit=16 LEDs
Drilling and Soldering the LEDs
Drilling:
Once i marked the location of the LEDs to be placed on the cardboard using pencil and scale (basic geometry and maths), providing some space at the right side (to place numbers/text to identify the bits), i used a small punch (sharp & round pointed tip of a screwdriver) to mark the LED positions. This small marker hole acts as a guide for the drill bit of 5mm to be accurate and perpendicular to the board. Remember we need to drill 64 holes in all so a bit of planning, precision and patience will help, lest we end up with a hole at the wrong place and start allover with a new cardboard. Try practicing on a scrap piece of cardboard to get a hang of how your drill handles the board. Once you are confident go ahead and drill all the holes one by one. Once all the holes are drilled (by mistake i drilled all the 6 positions of hours where i need only 4 positions), pls inspect the holes for perfection and clean passage. LEDs will sit here and need to be @ 90 degrees to the board.
Inserting LEDs & Soldering:
Group the LEDs which you have chosen for the hours, minutes and seconds separately. Start with one color LED and with groups of 4. Bend the Anode lead of all 4 LEDs at 90 degrees away from the body. See picture. insert the first LED which will be the base LED around which you will plan the other 3 LEDs. If the LED does not slide into the slot, pls use your drill bit a little more here to polish/buff the insides of the hole so that the LED slides in comfortably but should not be too loose in fitting in. Align the other three LEDs in such a way that all the 4 LED anodes are in one bunch and the cathodes are pointing outwards. Now carefully bend the cathodes carefully using a long nose pliers to form a bridge kind of structure with each leads touching other. Take care to ensure that nowhere the anodes and cathodes touch each other. See picture.
Now solder the leads together as we had bunched them so that all 4 LEDs are wired in parallel. (ensure that you choose all LEDs of one color from same lot/bunch/manufacturer to avoid differences in the drive voltages or brightness variations as we are bunching them in parallel in groups of 4).
Once you have soldered all the LED leads together with bunching, use multistrand wires to connect all anodes together as we will drive them using their cathodes to light each bunch individually.
Testing the display board:
Once your soldering is complete, connect a 5 volts supply in series with a 680 ohm or a 1 Kohm resistor in series (mandatory to ensure you do not burn LEDs with high voltage while checking) and check each LED cluster individually for lighting and alignment. Any corrections on alignment of the LEDs can be done now as needed. Once you are satisfied on the display panel, use hot glue gun and seal the LEDs in their places (LEDs tend to pop out of their slots when disturbed slightly due to the tension on their leads post soldering) use liberal quantities of hotglue between the LEDs and the cardboard base to ensure they do not budge when pulled or moved once the glue cools down.
Programming the Arduino & Testing the Sketch
I used the sketch used by :https://www.instructables.com/id/LilyPad-Arduino-Bi...
with minor modifications to suite the arduino board i had bought. This was the pro mini i bought from Ebay for around Rs 200. The sketch used is below:
#include
int hourLEDs[] = {5, 4, 3, 2}; //list in order of with 1 first int minuteLEDs[] = {A4, A3, A2, A1, A0, 13}; int secondLEDs[] = {11, 10, 9, 8, 7, 6}; // pin 11=LSB=1, pin10=2, pin9=4, pin8=8, pin7=16,pin6=32 seconds int loopLEDs[] = {A4, A3, A2, A1, A0, 13, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2};
int switchPin = 0;
void setup()
{ for (int i = 0; i<4; i++) { pinMode(hourLEDs[i], OUTPUT); } for (int i = 0; i<6; i++) { pinMode(minuteLEDs[i], OUTPUT); } for (int i = 0; i<6; i++) { pinMode(secondLEDs[i], OUTPUT); } setTime(0); }
void loop()
{ if ((digitalRead(switchPin)==0 )) //when switch is activated, time speeds up so you can set time { adjustTime(1); } else
if (minute() == 0 && second() == 0) { spin(hour());
}
updateDisplay(); delay(1); }
void updateDisplay() { time_t t = now(); setOutput (hourLEDs, 4, hourFormat12 (t)); setOutput (minuteLEDs, 6, minute(t)); setOutput (secondLEDs, 6, second(t));
}
void setOutput (int *ledArray, int numLEDs, int value) { for (int i = 0; i < numLEDs; i++) { digitalWrite (ledArray[i], bitRead (value, i)); } }
void spin (int count) //spins the lights for each hour { for (int i = 0; i < count; i++) { for (int j = 0; j < 16; j++) { digitalWrite (loopLEDs[j], HIGH); delay(50); digitalWrite (loopLEDs[j], LOW); } } }
Since the Arduino board does not have a USB interface, i had used a USB to TTL interface and used the connectors and pushed the sketch into the board via my desktop computer USB port and Arduino IDE. Once the programming is done, you can debug and test the working of the sketch by using single LEDs hooked up with 560ohm current limiting resistors on a breadboard just to ensure that the sketch works as uploaded. You can hook up 6 LEDs at a given time and check the hours, minutes and seconds pins separately for working. This is just to ascertain that the software works as defined and there are no surprises later.
Power Supply, Driver Hardware and Connecting All Together
The circuit schematic is uploaded as a picture above.
For the power supply i used an existing 230 to 6-0-6v step down transformer coupled with a 1A 50 V brdige rectifier and a 2200 Microfarad 25V smoothing capacitor. Here since i had surplus regulator chips, i used LM 317 and 7805 for LED driving voltage and for the Arduino respectively. I know i could have used mosfets etc to control the LEDs but wanted to use what was available. Idea of 317 variable voltage regulator is to crudely control the LED brightness using the output voltage with the help of the 5 K pot. Since rectified Raw DC was > 12 volts i did not want to risk the Arduino board with this high voltage (via the raw input power pin) and since the voltage drops down to 1.2 volts min on extreme setting of the potentiometer, which will not work the Arduino, i used a regulator in parallel (7805) for constant regulated 5 V for the Arduino board.
Since i had plans later to use lamps or larger load instead of the 4 LED cluster, i wanted to future proof the circuitry.Some leftover NPN darlington ICs (ULN 2003A) were available, i made use of them using one chip for hour minute and second pins. (each ULN 2003A has 7 darlington pairs inside, i used 6 on two chips for seconds and minutes and 4 for hours). See schematic for details.
Since same voltage is applied is common across all LEDs and we are using three colors here, drive voltages will be different for different color LEDs and currents too will differ. Please run a small experiment on a bread board to rig up the 3 different colored LEDs (not the ones already soldered but from the same lot) and using various current limiting resistor values, figure out the best resistance values to ensure there is uniformity in the brightness levels for a given voltage (best to test at max voltage of 12 volts using the power supply designed). I have derived the resistor values in circuit based on my experiments.
I soldered all the components on a general purpose PCB as it is pretty simple circuit to rig up. Started with IC bases and resistors (little awkward soldering as i needed to align 1/2 watt resistors to the 20 pin headers. Later completed all the connections and wiring as per the schematic. See pictures above. Separated the power supply board with bridge rectifier, filtering capacitor and 2 voltage regulator ICs for flexibility in fixing into an enclosure and for modularity used PCB headers with screw terminals for serviceability later.
I am yet to put this into a good enclosure and conclude the project :)
Will update the final enclosure photos shortly
Happy new year 2016!