John Bradnam
Published © GPL3+

Gear Clock 2

A 3D printed clock driven by a single stepper motor using gears to separate hours, minutes and seconds.

IntermediateFull instructions provided8 hours872
Gear Clock 2

Things used in this project

Hardware components

Stepper Motor
Digilent Stepper Motor
28BYJ-48 (5V)
×1
Microchip ATtiny1614 Microprocessor
×1
1N4148 – General Purpose Fast Switching
1N4148 – General Purpose Fast Switching
SOD-323 Package
×4
AO3400 N-Channel MOSFET
SOT-23 Package
×4
Mini USB socket
Surface Mount
×1
0805 Passive Components
4 x 1K OHM, 4 x 10K OHM, 1 x 0.1uF
×1
Hardware
OD3mm L14mm, L22mm, L33mm Metal such as Cu tube or rod; OD4mm ID3mm L6mm Metal such as Al tube for hour hand; M3 t4mm x 6pcs insert nuts such as https://www.aliexpress.com/item/33008141694.html; M3 bolt L8mm 3pcs, L6mm 3pcs; Option: 3mm L50-100mm rod to make it stable.
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)
Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Custom parts and enclosures

Arduino Gear Clock

Schematics

Schematic

PCB

Eagle Files

Schematic and PCB in Eagle format

Code

GearClockV2.ino

C/C++
/**
 * GEAR CLOCK V2
 * 
 * 2021-08-13 Software by Tada3 (https://www.thingiverse.com/thing:4930786)
 * 2021-11-04 John Bradnam (jbrad2089@gmail.com)
 *    - Changed hardware from Arduino Nano to ATtiny1614
 *    - Replaced ULN2003A wih 4 N-Channel MOSFETs
 * 
 * ATTiny1614 Pins mapped to Ardunio Pins
 *
 *             +--------+
 *         VCC + 1   14 + GND
 * (SS)  0 PA4 + 2   13 + PA3 10 (SCK)
 *       1 PA5 + 3   12 + PA2 9  (MISO)
 * (DAC) 2 PA6 + 4   11 + PA1 8  (MOSI)
 *       3 PA7 + 5   10 + PA0 11 (UPDI)
 * (RXD) 4 PB3 + 6    9 + PB0 7  (SCL)
 * (TXD) 5 PB2 + 7    8 + PB1 6  (SDA)
 *             +--------+
 *             
 * BOARD: ATtiny1614/1604/814/804/414/404/214/204
 * Chip: ATtiny1614
 * Clock Speed: 20MHz
 * Programmer: jtag2updi (megaTinyCore)
*/

#include <Stepper.h>

#define IN_1 0 //PA4
#define IN_2 1 //PA5
#define IN_3 2 //PA6
#define IN_4 3 //PA7

const int NUMBER_OF_STEPS =64;
const int RPM =7;
const float GEAR_RATIO = 64;
int csec;

Stepper myStepper(NUMBER_OF_STEPS, IN_1, IN_3, IN_2, IN_4);


//---------------------------------------------------------------------
//Set up clock
void setup() 
{
  myStepper.setSpeed(RPM * GEAR_RATIO / 2.0); // speed for movement
  csec = 0;
}

//---------------------------------------------------------------------
//Main program loop
void loop() 
{ 
  delay(1000-1000/RPM-59);    // delay for 1 min, 1000ms-60000ms/RPM/60-proc.time
  int sStep = (csec % 8 == 0) ? 35 : 34;
  myStepper.step(sStep);  // step for 1 sec, 35x8+34x52=2048
  stopMotor();
  csec = (csec == 59) ? 0 : csec + 1;
}

//---------------------------------------------------------------------
//Stop motor to save power

void stopMotor() 
{
  digitalWrite(IN_1, LOW);
  digitalWrite(IN_2, LOW);
  digitalWrite(IN_3, LOW);
  digitalWrite(IN_4, LOW);
}

Credits

John Bradnam

John Bradnam

146 projects β€’ 179 followers
Thanks to Tada3.

Comments