Mechanical Seven Segment Display Clock

47,858

495

80

Introduction: Mechanical Seven Segment Display Clock

A couple of months ago I built a two digit mechanical 7 segment display which I turned into a countdown timer. It came out quite well and a number of people suggested doubling up on the display to make a clock. The problem was that I was already running out of PWM IO on my Arduino Mega and didn't have enough available for the second or third digits. I was then pointed in the direction of these PCA9685 16 channel PWM drivers which operates over an I2C interface. These made it possible to drive the 28 servos I needed all using the two I2C pins on an Arduino. So I got to work building a clock which now uses a DS1302 real time clock module to keep the time and two 16 channel servo drivers to control the 28 servos used to make up the display, all powered by an Arduino Uno.

If you enjoy this Instructable, please consider voting for it in the Clocks Contest

Supplies:

To build your clock, you'll need the following supplies in addition to some basic tools:

For this project you'll also need some 3D printed parts. If you don't already have a 3D printer and you enjoy making thing then you should definitely consider buying one. The Creality Ender 3 Pro used here is affordable and produces pretty good quality prints for its price.

Step 1: 3D Print the Plastic Components

I designed the 7 segment displays to be as simple as possible. The servo is also the support bracket to hold up the segment above it. There are two 3D printed components required for each segment, a spacer block to support the bottom side of the servo and the display segment which glues directly onto the servo arm.

Download the 3D Print Files - Mechanical 7 Segment Display Clock 3D Print Files

Print the servo segments and dots using a bright coloured PLA. I used translucent green, but red, orange or yellow should work well too. I used black PLA for the spacer blocks and dot supports so that they aren't visible when the segments are turned to the off position.

If you don't have access to a 3D printer, try out one of the online printing services. There are a number of affordable services available which will print out the components and deliver them to your door in a few days.

Step 2: Prepare Your Control Boards & Wiring

You'll need to use two PCA9685 16 channel PWM drivers to drive your 28 clock servos. I separated the servos into the hour and minute digits, with each pair of digits being driven by one board. So I have one board controlling the servos for the two hour digits and the second controlling the servos for the two minute digits.

To chain the two together, you'll need to make up a 6 wire ribbon cable connector and solder a second header strip onto the other end of the first servo control board. You'll also need to change the I2C address on the second board so that it is different to the first and uniquely identifiable.

You'll also need to make up the wiring harness to connect the three boards (two servo boards and the clock module) to your Arduino. You'll need 5V and GND to each board as well as the I2C connections to your Arduino pins A4 and A5 (I2C on Arduino Uno), and the clock module pins CLK, DAT & RST to pins 6,7 & 8 on your Arduino respectively.

Power is supplied to the Arduino directly from the 12V power supply and to the servos using the 5V 5A BEC which is then connected to the two terminals on the top of the PWM driver. You only need to connect one servo driver to power and it will feed power to the second through the 6 wire ribbon cable connection.

Step 3: Assemble the Servos

Once you've printed your segments you'll need to spray the back and sides black so that they're less visible when they're turned 90 degrees to the off position.

You then need to glue the segments onto your servo arms with hot melt glue. It helps to glue them onto the servo with the arm already on the servo, this way you can check that you're gluing them on straight and level.

You'll also need to glue a spacer block onto the bottom of each servo.

Assemble the dots by gluing a small dowel or kebab stick into the back of the dots and then into the base blocks. I sprayed these sticks black as well so that they're less visible if viewed from an angle.

Step 4: Set Up & Testing

I numbered all of the servos and wrote the number onto each lead so that it was easier to keep track of them. I started with the top segment on the units digit and worked around to the middle segment on the tens digit. This is also the order in which I plugged them into the servo control boards, remembering that the identifiers on the boards count from 0 to 13 and not from 1 to 14.

I then set the segments up on a table with enough space between them for testing so that they didn't move into one and other while getting the travel limits and directions set up. If you try set them up close together you'll likely have one or two try to move in the wrong direction or over travel at some stage and hit another which may damage the segment, servo arm or strip the gears on the servo.

Step 5: Uploading the Code

The code looks complicated at first glance, but it's actually relatively simple thanks to the two libraries used. There is also a lot of repetition because there are four different 7 segment displays needing to be updated.

Here's a summary description of the code, have a look at the full guide for a more detailed explanation and a link to download the code - Mechanical 7 Segment Display Clock

We start by importing two libraries, virtuabotixRTC.h for the clock module and Adafruit_PWMServoDriver.h for the servo drivers. The Adafruit library can be downloaded and installed directly through the library manager in the IDE.

We then create an object for each control board with the relevant address, one for the hour digits and one for the minute digits.

We then have four arrays to store the on and off positions for each servo. You'll need to make adjustments to these numbers in the coming steps to make sure that your servos are upright when on, turned 90 degrees when off and don't over travel.

A digit array stores the positions of each segment for each digit to be displayed.

We then set up the clock module and create variables to store the current and past individual digits.

In the setup function we start and set up the PWM control boards as well as update the clock time if required. We then run through a loop to set the display to 8 8 : 8 8 so that we know the starting position of all of the servos. This is also used to set up the servos so that they're all facing upwards correctly.

In the main loop we get the updated time from the clock module, spilt it into the four digits and then check whether the time has changed from the last check. If the time has changed then we update the display and then update the previous digits.

In the update display function, we first move the middle segments. This is done first because there is some logic required to move the two top segments adjacent to the middle segment out of the way a little before moving the middle segment, otherwise it will bump into them. Once the middle segments are moved then the remaining segments are moved the the correct positions.

Step 6: Assembling the Clock on the Back Board

Once I was done with the testing, I assembled the servos onto the back board using the above layout as a guide.

The white area is the overall board size, the lighter grey is the area surrounding each digit where the servo segments move into and the outline on the dark grey area is the centre line for the outer 6 segments for each digit.

I cut the board, marked up the layout and then glued the digits in place to make up the clock face.

I then drilled holes near each servo and fed the wires through to the back of the board so that they're less visible.

I mounted the electronics onto the back of the clock with double sided tape.

Step 7: Final Setup & Operation

Once the servos were all ready, I removed all of the servo arms for the final adjustments to the positions of the segments. You should power up the Arduino in this state so that 8 8 : 8 8 is displayed and then disconnect the power, this re-centres all of your servos so that you can put the servo arms back on with the segments facing as close to vertical as possible.

You'll then need to sequentially power up your Arduino and make adjustments to your segment on and off positions in your four arrays so that the servos are perfectly vertical when on and turn through 90 degrees when off without over travelling. This step is quite time consuming and requires a bit of patience but the end result is well worth it!

The clock can be left powered using the 12V power supply and 5V BEC connected to it. If the power goes down, the battery on the RTC module will keep the time so that when power is restored, the clock automatically resets to the correct time.

If you enjoyed this Instructable, please vote for it in the Clock contest and let me know of any improvements or suggestions you can come up with in the comments section below.

Clocks Contest

Second Prize in the
Clocks Contest

3 People Made This Project!

Recommendations

  • Microcontroller Contest

    Microcontroller Contest
  • Automation Contest

    Automation Contest
  • Make it Glow Contest

    Make it Glow Contest

80 Comments

0
anachum
anachum

Question 2 months ago on Step 7

hi DIYLIFE(Michael) Any chance adding time adjustments bottoms? to adjust hour, for DST and fine adjust minutes? tnx
Amos

0
RonaldB1989
RonaldB1989

2 months ago

What 3D cad application did you use to create the pieces?

0
thediylife
thediylife

Reply 2 months ago

I just used TinkerCAD online for these parts

0
gyetton
gyetton

2 months ago

That's really nice, one suggestion if each segment also had a black section that moved into view as the green section moved out of view, it would hide the servos.

0
thediylife
thediylife

Reply 2 months ago

Nice idea, thanks. I was thinking of 3D printing a small black shroud over each of the servos to cover them.

0
Bassbuddy
Bassbuddy

10 months ago on Step 7

Arduino.....Clock module.... Mechanical? Rubbish!!

0
squarej
squarej

Reply 10 months ago

Are you kidding? This is sweet!

0
Bassbuddy
Bassbuddy

Reply 10 months ago

It is fake. If it ain't mechanical dont call it so!!! It annoys me.

1
jkaiser20.
jkaiser20.

Reply 2 months ago

Seems you need to work on some things chief. It is exactly as titled. It is a clock with mechanical seven segment displays. Seems 45 years of electronics left a short or two...lighten up Francis, this is a cool project, nothing fake about it.

0
NeilRG
NeilRG

Reply 10 months ago

You see its a DIGITAL clock. It uses geared servomotors which are definitely MECHANICAL. Did you actually expect such a clock to be driven by an escapement mechanism, spring, and gears?? Do you get off on being a troll.?Could you personally build the MECHANICAL clock you thought this was?? It may not be something you like, but to call someone else's work RUBBISH in just NASTY!

0
Bassbuddy
Bassbuddy

Reply 10 months ago

I know what it is. You don't have to tell me. It is an electronically driven clock with a mechanical readout. As such it is a fine piece of work, although I must be honest to say Idon't appreciate it very much. My "rubbish" relates to the use of the term "mechanical" which indeed gives a wrong impression. And yes I was kind of dissappointed to find out that "only" the display was mechanical. And I also realize that electronics as part of the solution is almost inevitable. I would have appreciated more mechanics in the project.
No idea what that has to do with being a troll. I am a retired engineer who worked for over 45 (fortyfive) years in ELECTRONICS, but I very much appreciate engineers in the mechanical field without whom any electronics would be impossible and useless.
But some people having the wrong idea that nothing goes without processors may be so arrogant to think that anything mechanical is obsolete.
I don't what you are getting off on but I have an impression.

0
NeilRG
NeilRG

Reply 10 months ago

I sensed the designers pride in the project and instructable and thought your post was harsh.

0
tarunmatliwala
tarunmatliwala

Question 5 months ago

Hi Mike, I have constructed this project & uploaded the code in aurdino. When I run the programme the real time clock is not working. All four digits are desplaying 00:00. Please suggest.

0
thediylife
thediylife

Answer 4 months ago

Hi,
Your question is really broad, there are a number of reasons why it wouldn't display the correct time.
I'd suggest as a start:
Check that your clock module is working, can you display the time on the serial monitor on your computer?
Check that your servos move by trying to display other numbers on them or moving them.

0
tarunmatliwala
tarunmatliwala

Reply 4 months ago

Thank you for reply.

Yes, You are right. I can not display the time on the serial monitor on the computer. Please guide me.



0
thediylife
thediylife

Reply 4 months ago

There's most likely a wiring issue to your clock module, or the module isn't working. Try checking your connections again.

0
tarunmatliwala
tarunmatliwala

Reply 4 months ago

Dear Mike,
I have checked the wiring of clock module and it is found ok. Also the clock module is working. But, still I am not getting the movement in servoes and not getting the output of serial monitor. Is there any changes in Code? Or any other issues.
Please suggest. Because I am very interested to build this project.
Thanks.

0
thediylife
thediylife

Reply 4 months ago

Hi Tarunmatliwala,
How are you displaying the clock information on the serial monitor? How do you know that the clock module is working if you can't see the output?
You'll need to add some serial.print lines to the code to output the clock values and troubleshoot your code to see where the problem is. I can't really help you without you knowing what the issue is, or where the issue is. There are hundreds of things that could be wrong with your setup or the code.
You'll need to work methodically through it and try getting the clock to display the output on your serial monitor. Then get a servo to move using one of the PWM modules, then try to connect both modules and get two servos moving etc..

0
tarunmatliwala
tarunmatliwala

Reply 3 months ago

Dear Sir,
Thanks for your suggestion, Now I am getting the time on display & servo is running accurately. Although I would like to know how to convert module time from 24 hour format to 12 hour format. Any changes in code ? Please advise.
Tarun Matliwala

0
thediylife
thediylife

Reply 3 months ago

I would just subtract 12 if the hours are greater than 12 before updating the hour display.