# Project: Clock Two – Single digit clock

Let’s hack an Ikea lamp into a single-digit clock! How? Read on…

Updated 18/03/2013

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.

Construction

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.

Software

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:

Hardware

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 twitterGoogle+, 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.

# Breaking up an automatic room deodoriser – part one

In this article we attempt to break down an automatic room deodoriser and have some fun.

Updated 18/03/2013

[Update – we won round two]

Today we are going to tear down an automatic room deodoriser. Why? Why not! After walking around the supermarket as one does, pontificating over the need for doughnuts – I noticed this package on sale for eight dollars:

What grabbed my attention was the words “movement sensor” and the price tag. A sensor by itself can cost more. Where’s the catch? I am sure the company makes their money back from selling the refills, in a similar method to ink cartridges and razor blades. Good for them. However, perhaps this can be good for us! So into the basket and home it came. My flatmates thought it was a lovely gesture to have one in the hallway. Hah! As Dave Jones would say, “don’t turn it on – take it apart!” So let’s go…

The can of spray went straight into the WC, nothing of interest there. Three alkaline AA cells were included:

Well that’s a good start, you can always use these in a camera or something else. Armed with a philips-head screwdriver and a pair of needle-nosed pliers, the entire assembly came apart very easily and without force. I must congratulate the designers, you almost get the feeling that this is designed to be repaired if broken, and not replaced. The process of disassembly was quite easy:

The front cover came off quite easily. The switch on the right enables/disables the movement sensor; the LED indicates the repeat mode for the spray; and the black switch controls the duration between sprays – off, 9, 18 or 36 minutes.

After removing the rear panel with four screws, we can see the motor and one of the two PCBs. Two more screws, and we can remove the electronics and mechanical sections:

This is the front-facing part of the motor board. The motor turns one direction then another to have the plastic ‘finger’ push down and release on the aerosol can nozzle. The gear ratios are quite large, allowing the motor to exert quite an amount of torque. The metal base board has some convenient mounting holes as well, so this could be reused easily. If you had a pair of these you could drive something that is quite heavy at a sedate speed.

Here is the main controller board, with nicely colour-coded JST connectors for leads to the motor, power source (those 3 x AA cells, 4.5V) and to the switch that turns the sensor on and off. The underside is very professional, all SMD:

The motion detector’s board plugs nicely into the main board, thanks to the 2×9 pin header and socket arrangement:

Now it is time to see how things work. The first step will be the motor – how much voltage and current does it use? I ran the motor without a load for thirty minutes at 4.5 volts DC – the  motor body did not warm up at all, a good sign that this voltage was suitable. With regards to current, there are two measurements to take – current while free-running, and under maximum load (i.e. feeding the motor 4.5 volts while holding the gears still). While free running, the current drawn was 34 milliamps:

… and when I held down the gears so the motor could not turn, the current drawn was 305 milliamps:

So now we have a nice strong motor that can run at 4.5 DC, and draws between 34 and 305 milliamps. That’s a good start. Furthermore, being able to stick the meter display to the desk lamp really makes life easy. Now it is time to investigate the detector. It had a few codes on the PCBs, such as KT-7964, Smart Motion A-06 and RB-S04 which I searched for on the Internet without any luck.

So the next thought was to feed it 4.5 volts DC, and use the Scanalogic2 to analyse any signals or voltages around the PIR sensor module to see what happens. However, the entire system was dead, it would not do a thing. The same problem occurred at four volts DC. No luck either. After the initial power up, the unit should light the LED for one second, then activate the motor for a “first spray” – but nothing. Hmmm.

So at this point we are at a brick wall, however this is not the end. Research will continue to look for details of the PIR unit, and once it is working independently a new post will be published.

This article also shows to me and others that not everything is a success first time. It can be disappointing, however it’s not the end of the world. With every failure comes knowledge which can be used the next time around. So subscribe to the web page updates, and keep an eye out in the future. High resolution images are available from flickr.

In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, 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.