Let’s hack an Ikea lamp into a single-digit clock! How? Read on…
Time for another instalment in my irregular series of clock projects. (Or should that be “Time for another instalment in the series of irregular clock projects”?) In contrast with the extreme “blinkiness” of Clock One, in this article we describe how to build this single-digit digital clock:
Once again the electronics of the clock will be based from an Arduino-compatible board with a DS1307 real-time clock IC added to the board. On top of this we add a shield with some extra circuitry and two buttons – but more on this later. The inspiration for this clock came from a product that was recently acquired at Ikea – the “Kvart” work lamp, for example:
If you are shopping for one, here are the Ikea stock details:
The goal is to place the electronics of the clock in the base, and have one single-digit LED display at the top of the neck which will blink out the digits. There will be two buttons under the base that are used to set the time. It will be powered by a 9V battery or an AC adaptor which is suitable for a typical Arduino board.
This article is a diary of my construction, and you can always use your own knowledge and initiative. It is assumed that you have a solid knowledge of the basics of the Arduino system. If not, review my series of tutorials available from here. Furthermore, feel free to modify the design to work with what you have available – I hope this article can be of some inspiration to you.
It is much easier to prototype the clock and get the Arduino sketch working how you like it before breaking down the lamp and building up the clock. To do this involves some jumper wires and a solderless breadboard, for example:
Although there are four buttons on the board we only use two. They are connected to digital pins eight and nine (with 10k pull-down resistors). The LED display segments a~g are connected to Arduino digital pins 0~6 respectively. The decimal point is connected to the pulse output pin of the DS1307 – which will be set to a 1Hz output to have a nice constant blinking to show the clock is alive and well.
If you are unfamiliar with operating the DS1307 real-time clock IC please review this tutorial. Operation of the clock has been made as simple for the user as possible. To set the time, they press button A (on digital eight) while the current time is being displayed, after which point the user can select the first digit (0~2) of the time by pressing button A. Then they press button B (on digital nine) to lock it in and move to the second digit (0~9) which is again chosen with button A and selected with button B. Then they move onto the digits in the same manner.
After this process the new time is checked for validity (so the user cannot enter invalid times such as 2534h) – and is ok, the clock will blink the hyphen twice and then carry on with the new time. If the entered time is invalid, the clock reverts back to the current time. This process is demonstrated in the following video clip:
You can download the Arduino sketch from here.
The parts required to replicate the Clock Two in this article are:
- One Arduino-compatible board with DS1307 real-time clock IC as described in this article
- One Arduino protoshield and header pins
- One common-cathode 7-segment LED display of your choosing
- Seven current-limiting resistors to reduce the output current from Arduino digital outputs going to the LED segments. In our example we use a 560 ohm resistor network to save time
- Two buttons and two 10k ohm pull-down resistors
- One meter of nine-core wire that will fit inside the neck and stand of the Kvart lamp – an external diameter of less than 6mm will be fine
- And of course – the lamp
The protoshield is used to hold the buttons, resistor network and the terminus for the wires between the LED display and the Arduino digital outputs, for example:
At this stage you will need to do some heavy deconstruction on the lamp. Cut off the mains lead at the base and remove the plastic grommet from the stand that surrounded the AC lead. Next, with some elbow grease you can twist off the lamp-shade unit from the end of the flexible neck. You could always reuse the lamp head and AC lead if wired by a licensed electrician.
Now you need to feed the multicore wire through the neck and down to the base of the lamp. You can pull it through the hole near the base, and then will need to drill a hole in the base to feed it through to the electronics as such:
Take care when feeding the cable though so you don’t nick the insulation as shown above. Leave yourself a fair bit of slack at the top which will make life easier when soldering on the LED display, for example:
The next step is to solder the wires at the top to the LED display. Make notes to help recall which wires are soldered to the pins of the display. If your soldering skills (like mine) aren’t so good, use heatshrink to cover the soldering:
Most displays will have two GND pins, so bridge them so you only need to use one wire in the multicore back to base:
At this point use the continuity function of a multimeter or a low-voltage power source to test each LED segment using the other end of the cable protruding from the base. Once you are satisfied the segments have been soldered correctly, carefully draw the cable back through the neck and base in order to reduce the slack between the display and the top of the lamp neck. Then solder the individual LED segment wires to the protoshield.
Now if you have not already done so, upload the sketch into the Arduino board – especially if you are going to permanently mount the circuitry into the base. A simple method of mounting would be using a hot glue gun, but for the purpose of demonstration we have just used blu-tac:
Although this does look a little rough, we are using existing stock which kept the cost down. If you are going to power the clock with an AC adaptor, you will also need to cut out small opening to allow the lead to protrude from the side of the base. And now for the resulting clock – our Clock Two:
So there you have it, the second of many clocks we plan to describe in the future.
In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitter, Google+, subscribe for email updates or RSS using the links on the right-hand column? And join our friendly Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other – and we can all learn something.