 # Individual Light Clock

Hi, I'm trying to work out how best to approach a project I'd like to build... The Arduino seems like it should do it but I'm afraid I'm struggling with working out the best place to start.

What I want to create is a clock which works by showing the time as a number of illuminated light bulbs.

So I would have the following setup of lightbulbs from left to right: Hours - Tens x 2 Hours - Units x 9 Minutes - Tens x 5 Minutes - Units x 9 Seconds - Tens x 5 Seconds - Units x 9

So to show the time 16:25:36 we would have... one light, six lights, two lights, five lights, three lights, six lights.

I'm assuming I should be able to work out the time and then break that down into component parts then use this to light up the relevant bulbs... but I'm not sure how to translate this into practice.

I can find lots of examples of binary clocks but nothing that seems to quite work like this.

Any help/guidance would be much appreciated... my electronics is pretty rusty as is my coding, but I'm willing to try and learn.

Thanks. Matt

Thats interesting, I am planning the same kind of clock. I am too busy to work on it right now, but was thinking of using a seven segment display for each digit and then decoding the seven segment output into the lights to turn on. very much lines of code I'm thinking.

at a minimum, you need to shift out 33 bits: largest time value displayed= 23.59.59,, 2+3+5+9+5+9= 33. That would be five 8-bit shift registers (33/8=4.125, but you can not, to my knowledge get a one bit shift register...). you divide your raw time value (in seconds) by 3600 (number of seconds in an hour) to get the raw hours time value, take the integer value of the raw hours and 1) store that in a digital hours variable, 2) subtract (that*3600) from the raw time to get remaining minutes/seconds. divide remaining minutes/seconds by 60 (number of seconds in a minute) to get raw minutes. Take the integer value if raw minutes and 1) stash it in a digital minutes variable, 2) subtract minutes (minutes variable*60) from remaining minutes/seconds to get remaining seconds. stash that into a digital seconds variable. feed digital seconds variable into a proc to break it down into Tens and Units. shift out Units, shift out Tens. feed digital minutes variable into the breakdown proc and shift out Units, shift out Tens. do the same for Hours... lock the shift registers and use the parallel bits to drive your lamps (with a mosfet switch).

Seems like a big waste to me, but it's your project. have fun.

It might simplify things somewhat to use 6 shift registers: Two four hours, two for Minutes, and two for Seconds. You wouldn’t use all 16 bits for each number but it would save some of the complexity of packing the bit fields more closely.

To convert from a number to a number of bits:

``````unsigned int bits = (1U<<number) -1;
``````

That will give you 0b0 for 0, 0b1 for 1, 0b11 for 2, 0b111 for 3, etc. All the way up to 0b0111111111111111 for 15. It won’t work for values over 15 but you only need values up to 9.

John, You make life too easy, besides, I thought the purpose of a microcontroller was to reduce the number of discrete parts in a project....

johnwasser:
It might simplify things somewhat to use 6 shift registers: Two four hours, two for Minutes, and two for Seconds. You wouldn’t use all 16 bits for each number but it would save some of the complexity of packing the bit fields more closely.

To convert from a number to a number of bits:

``````unsigned int bits = (1U<<number) -1;
``````

That will give you 0b0 for 0, 0b1 for 1, 0b11 for 2, 0b111 for 3, etc. All the way up to 0b0111111111111111 for 15. It won’t work for values over 15 but you only need values up to 9.

I like this, but to add… you could do the actual counting using only shifts. For each digit, a count increment is just a left shift in a 1. Then clear the register and carry 1 to the next digit on overflow.

123Splat: at a minimum, you need to shift out 33 bits: largest time value displayed= 23.59.59,, 2+3+5+9+5+9= 33.

That is where I lost you.

I'm assuming that an output pin on the shift register is used to control a light bulb. i.e. set it 1 turn the light goes on, set it 0, turn off the light. You would need 2+9+5+9+5+9 = 39 bits not 33 bits to control all 39 lights. In other words just because 23:59:59 is the largest time displayed you still have to be able turn on the lights for ones digit of 4,5,6,7,8,9

In the bigger picture if I were building something like this I'd use a ws2812 led strip. WS2812 leds and strips are way cool for controlling lots of leds as they are easy to use and the wiring is very simple.

Get the 1M 60 led strip. Cut the strip to size, or cut into segments and arrange vertically as desired - If multiple vertical segments are used, simply run wires between the segments. The library will let you address all the individual LEDs and make them any color or brightness you want. Only a single pin is needed and no other h/w. You could have it up and running very quickly. You could put it in frame behind the translucent plastic used in flourscent drop ceilings.

--- bill

LED Strip is a good idea. Note that some strips can only be cut into 2, 3, or 4 LED segments. If you use a strip requiring 3-LED segments you'd use 3+9+6+9+6+9 LED segments requiring 42 LEDs. For 2-LED segments you would use 2+10+6+10+6+10 or 44 LEDs. For 4-LED segments you'd use 4+12+8+12+8+12 or 56 LEDs. A 60-LED strip would be enough for any of these designs.