Project tutorial
Servo clock with digital display

Servo clock with digital display © GPL3+

This project uses and Arduino Nano, a DS1307 RTC, a 5V power supply, and three servos to display the time in a digital format.

  • 997 views
  • 0 comments
  • 8 respects

Components and supplies

About this project

I Wanted to make a clock using servos that would display the time digitally. To do this the servos needed to move three disc, two disc to display the minute and one disc to display the hour.

I calculated that the disc needed to be 3.5" in diameter to allow the use of 18 pt Ariel Black font type to size the numerals and allow for 12 degree servo movement.

MAKING THE TIME DISC:

To prepare the disc, I used 3" i.d., 3.5" o.d. PVC pipe and a 3/32" thick foam board insert.

MAKE THE DISC PARTS:

The minute discs are 1/4" wide, Make 2.

The hour disc needs to be 1" wide, make 1.

The foam insert 3" outside diameter. Make 3

CONSTRUCT THE DISC:

Hot glue the servo connectors to the three foam inserts.

Hot glue the foam insert with the servo connector into the PVC pipe, two 1/4" minute disc

Hot glue the foam insert in 1" wide hour disc.

MOUNT THE DISC ON THE SERVOS AND APPLY THE NUMBER STRIP:

Numbers for servo 1 are 0 - 9, numbers for servo 2 are 0 - 5, numbers for servo 3 are 1 - 12.

Attach the discs to the servo motors and tighten the screw.

To position the numbers correctly on the disc use the "servo library" to:

Set servo 1 to 0 degrees. Mark a line on the disc in line with the flat part of the servo. Align the center of the 0 digit with this line. Glue the number strip around the disc. Photo:

Set servo 2 to 120 degrees. Mark a line on the disc in line with the flat part of the servo. Align the center of the 0 digit with this line. Glue the number strip around the disc. Photo:

For the hour disc, set servo 3 to 132 degrees. Mark a line on the disc in line with the flat part of the servo. Align the center of the number 1 on this line. Glue the number strip around the disc. Photo:

This arrangement works with the program as written using a 3.5" o.d. disc and numerals printed in 18 pt Ariel Black font. This can be adjusted to different disc diameters by altering the incremental movement of the servos and changing the font/size of the numerals.

MAKE THE SERVO MOUNT:

The servo mounts are made of sheet metal, easy to cut and bend.

ATTACH THE SERVO MOUNT TO A BASE:

Servo mounts attached to a section of 1 X 4 pine board.

ATTACH THE SERVOS TO THE MOUNT:

Fasten the servos to the mount with a zip tie.

The circuit is simple as shown in the diagram. The code is simple and sets the time on the RTC to the time the sketch is run. The power provided by an Arduino Nano is probably not of sufficient amperage to power 3 servos therefore I used a separate 5V supply for the servos and the Arduino.

Enclosure for the clock can be simple or as complicated as you desire. I chose a simple mask front to frame the time.

Code

ServodigitArduino
Arduino code file
#include <SPI.h>

#include <Wire.h>
#include "RTClib.h"
#include <Servo.h> 

Servo myservo1;  // single minute servo connects to arduino pin 9          
Servo myservo2;  // tem minute servo connects to arduino pin 8
Servo myservo3;  // hour servo connects to arduino pin 7

int pos1 = 0;    
int pos2 = 0;
int pos3 = 0;

RTC_DS1307 rtc;





void setup() {
  // put your setup code here, to run once:
  myservo1.attach(9);
  myservo2.attach(8);
  myservo3.attach(7);

  Serial.begin(9600);
  if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    while (1);
  }

  if (! rtc.isrunning()) {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));

  }
}

void loop() {
  DateTime now = rtc.now();

  int h=now.hour();
  int m=now.minute();
  int nm;  // variable used to convert to minute single digit

  // following line converts from 24 hour to 12 hour
  if (h>12) {
    h=h-12;
  }

  Serial.print(h);
  // following lines position the hour disc
  if(h==1){
    pos3=132;
  }
  if (h==2){
    pos3=120;
  }
  if (h==3){
    pos3=108;
  }
  if (h==4){
    pos3=96;
  }
  if (h==5){
    pos3=84;
  }
  if (h==6){
    pos3=72;
  }
  if (h==7){
    pos3=60;
  }
  if (h==8){
    pos3=48;
  }
  if (h==9){
    pos3=36;
  }
  if (h==10){
    pos3=24;
  }
  if (h==11){
    pos3=12;
  }
  if (h==12){
    pos3=0;
  }





  Serial.print(":");
  Serial.print(m);
  //following lines position the minutes discs
  if (m<10){
    nm=(m);
    pos2=120;
  }
  if (m>9){
    nm=(m-10);
    pos2=108;
  }
  if (m>19){
    nm=(m-20);
    pos2=96;
  }
  if (m>29){
    nm=(m-30);
    pos2=84;
  }
  if (m>39){
    nm=(m-40);
    pos2=72;
  }
  if (m>49){
    nm=(m-50);
    pos2=60;
  }


  Serial.println();
  Serial.print(nm);
  pos1=(nm * 12); // this line determines the servo 1 movement
  myservo1.write(pos1);
  myservo2.write(pos2);
  myservo3.write(pos3);

  Serial.println();
  Serial.println();
  Serial.print(pos1);
  Serial.println();
  delay (1000);

}

Schematics

servodigit
diagram
servodigit_bZzGU8oX4V.fzz

Comments

Similar projects you might like

Digital & Binary Clock In 8 Digits x 7 Segments LED Display

Project tutorial by LAGSILVA

  • 3,749 views
  • 3 comments
  • 11 respects

Complete Digital Clock Including Alarm and Motion Sensor

Project tutorial by LAGSILVA

  • 21,318 views
  • 22 comments
  • 73 respects

Digital Clock with Mirrored Display Driven by Accelerometers

Project tutorial by LAGSILVA

  • 16,444 views
  • 2 comments
  • 42 respects

Arduino Cheap Minimal Parts Digital Clock

Project showcase by garysat

  • 16,429 views
  • 38 comments
  • 33 respects

4-Stroke Digital Clock With Arduino

Project tutorial by LAGSILVA

  • 14,930 views
  • 15 comments
  • 45 respects

Digital And Binary Clock With Two LED Matrix And RTC

Project tutorial by LAGSILVA

  • 12,581 views
  • 41 comments
  • 46 respects
Add projectSign up / Login