Arduino controlled Clock

Arduino controlled Clock

by stuart.a.rucker | updated August 01, 2014

My goal is to make an Arduino based clock with an alarm and Time-Set using as few input/output pins as possible. The hours will be displayed by lighting up 1 of 12 LEDs around the perimeter of the clock face. The minutes will be displayed using two 7-segment displays, and the seconds will be displayed by a rotating seconds dial in the center, powered by a Servo. The frame will be laser cut.



The goal of my project is to master shift registers and other circuitry to maximize the functionality of the Arduino without using up an excessive amount of pins. This way, I will easily be able to connect and disconnect the Arduino without much toyle.

I am making a laser cut Arduino based clock out of plexigalss which will display the hours, seconds, and minutes.

  • Minutes will be displayed by 2 7-segment displays
  • Seconds will be displayed by a rotating dial in the center
  • Hours will be displayed by 12 LEDs arounf the outside of the clock

The Using 2 buttons, 2 switches, and a buzzer, I will make a control panel on the side of the clock which can set the time and alarm. 



  • Plexiglass and wood
  • 2 buttons & 2 switches
  • 4 shift registers (sn74hc595n)
  • Lots of wire
  • Heat Shrink tubing
  • Breadboard
  • resistors
  • 7-segment display
  • Servo
  • Arduino
  • ​buzzer
  • 12 10mm LEDs


  • transistor and light coil.
  • Photo resistor


July 29, 2014 at 11:51 AM
Comments (0)


A shift register is a chip which also receives sequential bits through a data line, but instead uses the information to either write High or Low its output pins. Using a shift register, a few Arduino pins can control many outputs.

Shift registers are a very important part of digital logic. They act as glue in between the parallel and serial worlds. They reduce wire counts, pin use and even help take load off of your CPU by being able to store data.

They come in different sizes, with different models for different uses, and different features. The one I will be using is the SN74HC164 8-bit, serial-in parallel-out, latched, shift register


A shift register is made up of flip flop circuits. A flip flop is 1 bit of memory. This chip has 8 (or 1 byte of memory). Since it is memory, if you do not need to update the register you can just stop "talking" to it and it will remain in whatever state you left it, until you "talk" to it again or reset power. 

Serial-in parallel-out
This means your Arduino sends the chip data serially (on off pulses one after another) and the shift register places each bit on the correct output pin. This model only requires 3 wires to be controlled, so you can use 3 digital pins on the Arduino, and break those 3 out to 8 ouputs.


Using a shift register to power LEDs


Refer to picture. Pins Qa though Qh represent the parallel outputs from the shift register. This is what you will hook up to LEDs.

  • VCC will connect to 5V.
  • GND will connect to a shared ground with the Arduino.
  • The SER pin is the data input. This is the pin where you will feed in 8 sequential bit values to set the outputs. Connect to Pin 8.
  • The SRCLK pin is represented by the CLOCK pin. A clock pin is needed so the shift register knows when a bit is ending and starting, as opposed to the baud rate in Serial Communication. Every time this pin goes high, the values in the shift register shift to the next pin by 1 bit. It will be pulsed 8 times to pull in all the data (all 8 bits) that you are sending on the data pin. Connect to Pin 10.
  • The RCLK pin is the Latch pin. The latch pin is used to “commit” your recently shifted serial values to the parallel outputs all at once. This pin allows you to sequentially shift data into the chip and have all the values show up all at once. Connect to Pin 9.
  • OE stands for output enable. The bar over the pin indicates that it is active low. In other words, when the pin is held low, the output will be enabled. In this example, connect the pin directly to Ground.
  • SRCLR pin is the serial clear pin. When pulled low, it empties the contents of the shift register. Connect it to 5V to prevent the shift register from clearing.



shiftout() is a built in Arduino function which takes care of writing all 8 bits and using the Clock pin.

shiftOut() takes four parameters

  • data pin
  • clock pin
  • bit order: The order that the bits are transmitted. MSBFIRST transmits the binary bits from the left, whereas LSBFIRST transmits the right-most bit first
  • Value to shift out: transmit 8 bits. Put a ‘B’ before the 0’s and 1’s to denote it is binary. Each 0 or 1 will control an output pin.


Test Project: I Connect 8 LEDs to the output pins and made a pattern. See attached code

Daisy chaining shift registers


More than just 8 outputs can be achieved from 3 Arduino pins by daisy chaining shift registers. 

Recall from the diagram the unused QH’ pin. Connect QH’ to the DATA(SER) pin of the next shift register.  The CLOCK pin and LATCH Pin can be shared. When there are more than 8 bits sent to the shift register, the oldest bit is transferred to the next shift register.


You can keep adding more and more shift registers, each connected to the last one. Just repeatedly execute shiftOut() once per shift register. The data sent first will end up in the last shift register.

See Attached Code.


Sources: Much of this was taken directly from and adapted from


July 29, 2014 at 12:00 PM
Comments (1)
Wow. What a great explanation. Thanks!
over 2 years ago

Using two shift registers, I connected the 7-segment display. The 7-segment display is the same as 7 LEDs bundled together. I connected each of the anode pins to a shift register output pin. They all share a common cathode (The middle of the 5 pins on the top and bottom). Make sure to use a resistor, I blew-out one of mine.

See the attached testing code which counts up to 60

July 29, 2014 at 12:05 PM
Comments (0)

To save input pins on the Arduino, instead of having each of the 2 buttons and 2 switches connected to a pin, I will connect them all to the same input. I will then cycle through each of the four switches using the shift register and write them high and then do a digital Read. If The reading is HIGH when I am using the shift register to only write one of the buttons HIGH, then I will know that the button is pressed. I was inpspired to save input pins like this by the Keyboard matricred. The Arduino Keypad library uses the same algorithm to check which of the 16 buttons is pressed.


I trick I learned is if you set the pinMode on an input from output to input quickly, the need for a resistor and ground connection is not necessary.


The attached code only scans two buttons. The real version will have 4.

The code attached works sometimes, but other times it doesn't work. I spent a while testing it and can't figure out why.
What I decided
I changed my input pin from 13 to 11. I suspect there was a problem because pin 13 is the default SPI clock line.
July 29, 2014 at 3:09 PM
Comments (3)
Can you describe what happens when it doesn't work? I used a multiplexer once to save on input pins; in principle, it's somewhat similar I think to using a shift register, so I'll see what I can do to help!
over 2 years ago
I have figured it out!

It was working about 30% of the time. Sometimes, the readings were random, and sometimes the readings were opposite of what you would expect. For example pressing the button would read LOW instead of HIGH. Doing things like pressing the reset button and re-uploading would make it work for a few seconds. I then changed my input pin from 13 to 11 and now it works.

I think it must have to do with pin 13 being the default SPI clock line
over 2 years ago
ah yeah, that makes sense. glad you got it figured out!
over 2 years ago

The clock face is laser cut from Plexiglass and wood.

I consists of 7 parts:

  1. Clock Face Front: This is the piece will 12 holes for the hour LEDs and a hole in the center for the seconds dial. It also has a whole for the 7-segment displays
  2. Clock Back: The same shape as the front but without any of the holes
  3. 4 supports: These are wooden beams which stick from the front to back to provide stability. The front and back have tiny holes so the supports stay in
  4. Control Panel. This fastens between the front and back the same way as the supports.It has 5 holes for the alarm buzzer, 2 switches, and 2 buttons.
  5. Base shaft. These two pieces of plexiglass stand vertically under the clock and elevate it off the ground. The clock front and back rests on grooves in this peice.
  6. Arduino and Breadboard shelfs This shelf connects the two base shafts and provides a place to rest the seconds servo, breadboard, and Arduino
  7. Base: This piece of wood rests on the ground and makes sure the base shafts do not slide with two groves
  8. Seconds dial: The servo will spin this part to indicate the seconds

The original Arduino shelf I made did not fit the breadboard, so I needed to laser cut another one. In the pictures is both the base which is too small and the final base


The corelDraw files which I used for the Laser Cutter will be uploaded soon.

July 29, 2014 at 3:40 PM
Comments (2)
I really like the look of the clock! I was curious about the combination of materials (wood and plexiglass). Any reason for this choice?
over 2 years ago
They were easily available and sturdy materials. I liked the opacity of the plexiglass. I used wood on the inner pieces because it is cheaper.
over 2 years ago

With 32 outputs, Wiring is a pain. Just Daisy Chaining the 4 shift registers on the breadboard took a long time.

 I modeled some of the parts of this project using Autodesk 123D circuits. You can even input Arduino code which it runs for you.

I found while doing this that Heat Shrink tubing helps alot. It is basically a plastic tube into which you stick all the wires you want to connect. Then heat it up and they will be stuck together. It is more flimsy than soldering but much easier. You also don't risk soldering two wires together which aren't supposed to touch (ie. the back of a button)

Wiring the 12 10mm LEDs to the clock face.

Using heat shrink Tubing, I connected long wires that could reach the breadboard to all of the LED anodes. To save time with the cathodes and resistors, I glued a wire around the back of the clock face, then soldered all of the cathodes to it. Since only one LED will be on at a time, the resistor value does not change so they can share the resistor and cathode. This saved me from needing 12 cathodes and 12 resistors.

Wiring the setting control panel

I soldered long wires onto one of all of the buttons' pins. Then I soldered all of the 2nd pins together for the single input. (See Testing buttons)

Wiring the 7 segment displays

Using heat shrink tubing I conneted all 14 anode wires to the heat shrink tubing. Then I connected the 2 cathodes, which all shared a common resistor.

I decided to have all 14 segments on the display share a resistor so I wouldn''t need to buy and connect each LED individually in the display. This does make it so that the brightness changes a little depending on how many LEDs are on. For example 4 LEDs for 11,and for 11 LEDs  for 59. It is not very noticeable.

Wiring the shift register

I used the same breadboard form "Testing Shift Registers" with 4 daisy chained shift registers.

Final Assembly

Wiring all the outputs in the particular order on the breadboard would have been nearly impossible. Instead I just stuck the wires in any outputs on the shift register which I could reach. I will then change the software to use my wiring.

  1. Before I did any more wire connecting I glued the laser cut base together. All of the connections are fragile so this will prevent them from moving. I ran into a problem; the wires protruding from the seven segment displays in the clock face were in the way of the breadboard. To make room for the breadboard on the top shelf of the clock. I needed to move the 7-segment displays outward, so that they poke out from the clock face. 
  2. I then tediously connected the 26 outputs for the 12 hours and two 7-segment displays. Certain wires were too short so I attached male-female jumper wires to them. (Basically wire extension cords)

Trouble shooting

I ran the shift register test code which sets all of the outputs to HIGH. Unfortunately, 6 of the hours LEDs and 5 of the 7-segment display LEDs did not work. 

Each one I trouble shot for errors using a multi meter and a power and ground wire.

Some errors were...

  • a burnt out LED
  • a wire with residue on the tip so it wasn't conductive
  • heat shrink tubing not connecting.
  • A particular breadboard hole not working
  • soldering errors.



July 29, 2014 at 4:49 PM
Comments (3)
The tip of using heat shrink is a good one. I also sometimes use hot glue as a way to insulate wires and also hold them in place. It's also really easy to remove hot glue if you buy some ethyl alcohol–applying just a little bit of it to hot glue loosens it and makes it really easy to remove!
over 2 years ago
Thanks. That's a good idea. I was worried before that it would be too difficult to reverse if I made a mistake. I will try out ethyl alcohol.
over 2 years ago
cool, I usually buy a container of ethyl alcohol from a drug store and ask them for some small plastic syringes that I can use to apply it to the hot glue more precisely.
over 2 years ago

Link Code to Wiring

Since I did not wire the LEDs onto the board in any particular way I needed to check to see what part of the code I needed to change to change the LEDs. I went through all four shiftouts in the testing shift register code and ran the code with B10000000, B01000000, B00100000, etc. I noted down which value for shiftout() controlled which LED.  For example the B00100000 in the 3rd shift out means that the 7-hour light turns on.

Write minutes and hours 

The way I structured the code to modify the shiftout() values is using 4 variables: shift1, shift2, shift3, shift4. These will be the values that I shift out. Instead of being binary, they will be decimal (i.e. B00000010 corresponds to 2).

Using an if statement for each LED,  I will either add, or not add the decimal number which would trigger the LED.

if(min2 == 0 || min2 == 2|| min2 == 3 || min2 == 5 || min2 == 6 || min2 == 8){
    shift2 = shift2 + 128;}

The above code would be for the bottom section of a 7-segment display, conneted to the pin which corresponded to B10000000 in the 2nd shiftout(). If the number, like 0, needs the bottom segment of the display to be activated, then the shift value will be modified accordingly.

Design Files
August 1, 2014 at 9:02 PM
Comments (5)
Wow, this looks fantastic! I especially like the lights on the periphery of the clock. What do you plan to use for your buzzer?
over 2 years ago
Wow, this looks like an intense clock. Great work so far!, It was awesome seeing you go through the whole process.
over 2 years ago
Thanks! The buzzer is embedded in the control panel.(see last photo of "wiring")
over 2 years ago
very cool to see the alarm video (and the moving seconds dial).

are you planning to build an enclosure for the back of the alarm clock (to encase the electronics)?

also, I was wondering if you've played around with midi or mp3 boards. it could be neat to program your own alarm music, though the buzzer would certainly scare me into waking up!
over 2 years ago
I initially had laser cut a clock black but I had so much wiring that it did not fit on. If I were to remake this project I would definitely get a custom printed circuit board. I just looked at the mp3 and midi boards. So cool! I will try to incorporate the into a future project.
over 2 years ago