Prototype Of a mechanical servo Clock.

What is it?

Most Digital clocks are made up of 4 7-segment display. A seven segment display is 7 leds arranged in specific manner that when some light up it forms a number ranging from 0-9 or letters from A-F.

Seven-segment display - Wikipedia

What the machincal clock does is used servo motors as an led. so when you see the carboard cutout from top it replicates led_on and when looked from side looks like led_off.

Parts Needed

I used :

  • Arduino Uno
  • !6 bit channel Servo Controller.
  • Carboard Cut hexagon shapes.

Math behind the Cardboard Cutouts.

I initially thought that cutting the hexagon cutouts was easy. In fact it was quite challenging. I had to find a perfect ratio.

  1. cut a rectangle with ratio 1:3 . I used 3:9 cm.
  2. draw a horizontal line across of length(1/2 of the short side ) from top and bottom of the long side. (Line T and B)
  3. Draw a verticle line from shor side to the other in the middle. ( center U and D)
  4. Connect U with edges Of T and D with B. then cutout thoses triangles to form a hexagon.
The diagram of one Hexagon. Recommended size is 3:9 cm but as long as the ratio is 1:3 the hexagons will fit perfectly

The code.


#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();

#define SERVOMIN  125 // this is the 'minimum' pulse length count (out of 4096)
#define SERVOMAX  575 // this is the 'maximum' pulse length count (out of 4096)

bool down=false;
uint8_t servonum = 0;
int ang[7];
void setup() {
  Serial.begin(9600);
  Serial.println("16 channel Servo test!");

  pwm.begin();
  
  pwm.setPWMFreq(60);  // Analog servos run at ~60 Hz updates
  setNum(1,8);
delay(1000);
}
void servo(int servoNum, int angleToMove){
  
  pwm.setPWM(servoNum, 0, angleToPulse(angleToMove) );
  }
void setNum(int digit, int numToSet){
  if(digit==1){
    switch(numToSet){
      case 0:
        if(!down){
        down=true;
        open();
        servo(1,180);
        close();
        }
        else{servo(1,180);}
        servo(2,90);
        servo(3,90);
        servo(4,90);
        servo(5,90);
        servo(6,90);
        servo(7,90);
        break;
        
      case 1:
        if(!down){
        down=true;
        open();
        servo(1,180);
        close();
        }
        else{servo(1,180);}
        servo(2,0);
        servo(3,0);
        servo(4,0);
        servo(5,90);
        servo(6,90);
        servo(0,0);
        break;
      case 2:
        if(down){
        down=false;
        open();
        servo(1,90);
        close();
        }
        else{servo(1,90);}
        servo(2,90); 
        servo(4,90);
        servo(0,90);
        servo(5,0);
         
        servo(3,0);
        servo(6,90);

        break;
      case 3:
        if(down){
        down=false;
        open();
        servo(1,90);
        close();
        }
        else{servo(1,90);}
        servo(2,90); 
        servo(4,0);
        servo(0,90);
        servo(5,90);
         
        servo(3,0);
        servo(6,90);
        break;
      case 4:
        if(down){
        down=false;
        open();
        servo(1,90);
        close();
        }
        else{servo(1,90);}
        servo(2,0); 
        servo(4,0);
        servo(0,0);
        servo(5,90);
        servo(1,90); 
        servo(3,90);
        servo(6,90);
        break;
      case 5:
        if(down){
        down=false;
        open();
        servo(1,90);
        close();
        }
        else{servo(1,90);}
        servo(2,90); 
        servo(4,0);
        servo(0,90);
        servo(5,90);
         
        servo(3,90);
        servo(6,180);

        break;
      case 6:
        if(down){
        down=false;
        open();
        servo(1,90);
        close();
        }
        else{servo(1,90);}
        servo(2,90); 
        servo(4,90);
        servo(0,90);
        servo(5,90);
        servo(1,90); 
        servo(3,90);
        servo(6,180);
        break;
      case 7:
        if(!down){
        down=true;
        open();
        servo(1,180);
        close();
        }
        else{servo(1,180);}
        servo(2,90);
        servo(3,0);
        servo(4,0);
        servo(5,90);
        servo(6,90);
        servo(0,0);
        break;
      case 8:
        if(down){
        down=false;
        open();
        servo(1,90);
        close();
        }
        else{servo(1,90);}       
        servo(2,90); 
        servo(4,90);
        servo(0,90);
        servo(5,90);
        servo(1,90); 
        servo(3,90);
        servo(6,90);

        break;
      case 9:
        if(down){
        down=false;
        open();
        servo(1,90);
        close();
        }
        else{servo(1,90);}
        servo(2,90); 
        servo(4,00);
        servo(0,90);
        servo(5,90);
        servo(1,90); 
        servo(3,90);
        servo(6,90);
        break;
      
      case 10: //A
        if(down){
        down=false;
        open();
        servo(1,90);
        close();
        }
        else{servo(1,90);}
        servo(2,90); 
        servo(4,90);
        servo(0,0);
        servo(5,90);
        servo(1,90); 
        servo(3,90);
        servo(6,90);

        break; 
       
      case 11: //B
        
        if(down){
        down=false;
        open();
        servo(1,90);
        close();
        }
        else{servo(1,90);}
        servo(2,0); 
        servo(4,90);
        servo(0,90);
        servo(5,90);
        servo(1,90); 
        servo(3,90);
        servo(6,180);

        break;
      
      case 12: //C
        if(!down){
        down=true;
        open();
        servo(1,180);
        close();
        }
        else{servo(1,90);}        
        servo(2,90); 
        servo(4,90);
        servo(0,90);
        servo(5,0); 
        servo(3,90);
        servo(6,180);

        break;
        
      case 13: //D
        if(down){
        down=false;
        open();
        servo(1,90);
        close();
        }
        else{servo(1,90);}
        servo(2,0); 
        servo(4,90);
        servo(0,90);
        servo(5,90);
        servo(1,90); 
        servo(3,0);
        servo(6,90);

        break;

      case 14: //e
        if(down){
        down=false;
        open();
        servo(1,90);
        close();
        }
        else{servo(1,90);}
        servo(2,90); 
        servo(4,90);
        servo(0,90);
        servo(5,0);
        servo(1,90); 
        servo(3,90);
        servo(6,180);

        break;

      case 15: //f
        if(down){
        down=false;
        open();
        servo(1,90);
        close();
        }
        else{servo(1,90);}
        servo(2,90); 
        servo(4,90);
        servo(0,0);
        servo(5,0);
        servo(1,90); 
        servo(3,90);
        servo(6,180);

        break;
        
      }
    }
  }
void open(){
  servo(4, 45);
  servo(5, 45);
  delay(20);
  }
void close(){
  delay(30);
  servo(4, 90);
  servo(5, 90);
  
  }
void loop() {
  
for( int i =0; i<16;i++){
setNum(1, i);
delay(1000);
}


}

int angleToPulse(int ang){
   return map(ang,0, 180, SERVOMIN,SERVOMAX);
}

I updated the code.

It has added funcionality for Letters A-F and Safer for a cutout to not overlap the other.

Until then goodbye!

Published by Hriday Barot's Blog

I am Hriday Barot

6 thoughts on “Prototype Of a mechanical servo Clock.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create your website with WordPress.com
Get started
%d bloggers like this: