Use three stepper motors to make the classic analog clock movement in the opposite direction.

Story
I wanted to make an analog clock that ran counter-clockwise. A nice lesson to not assume the normal is very normal at all. There really is no reason other than convention for a clock to turn the direction around the circle it does.

Since the classic DIY positioning servos I’ve implemented have a 180-degree working range, I decided to use a stepper motor.

A circle is broken into 360 degrees also by convention only. However, the number 360 is quite convenient due to the quantity of numbers that divide evenly into 360. The number of hours, minutes and seconds divide evenly into 360. As a result each hour represents 30 degrees of rotational travel, each minute is 6 degrees of travel and same for seconds.

This code calculates absolute “MoveTo” positions with the information in mind.

However, there is a bug that I cannot resolve. The code uses the AccelStepper library and there is one move that is incorrect that I cannot find the bug in the code/logic. It is more obvious on the seconds hand since the problem arises every 60 seconds. Problem is same on hours and minutes but is more easily tolerable since happens twice per day on hour hand and only once per hour on the minute hand.

Exact steps to reproduce the problem:

The second hand makes the correct move of 6 degrees in the counter-clockwise direction from second value 58 to 59. Same for move from 59 to 0. The minute hand makes it’s 6 degree move at the transition of second hand from 59 to 0. However, on the next second hand move (from 0-1), the second hand servo makes the long move in the clockwise direction.

The motor eventually catches up since it runs at faster than 6 degrees per second. Same problem exists with code for other motors. I experimented with negative speed commands and other things without success.

I prefer to not use incremental moves due to accumulated error and the need to write code that puts the motor ahead of the actual seconds value of the Arduino clock time to sync as clock time “passes” the current motor position or similar.”