Steppers vs Servos

Moving the Hands

For the clock hands, we need continuous rotation and precise positioning.

  • Servos: Good for 0-180 degrees. Bad for continuous rotation.
  • DC Motors: Good for speed. Bad for precision.
  • Stepper Motors: The best of both worlds!

The 28BYJ-48 Stepper

This motor moves in tiny "steps". To make a full circle, we have to tell it to take exactly 2048 steps (depending on the gear ratio).

CPP
#include <Stepper.h>

const int stepsPerRevolution = 2048;
Stepper myStepper(stepsPerRevolution, 8, 10, 9, 11);

void setup() {
  myStepper.setSpeed(10);
}

void loop() {
  // Move one minute forward
  myStepper.step(stepsPerRevolution / 60);
  delay(60000);
}
We use the stepper for the minute hand because it needs to move precisely 360 degrees over and over again.