// This is a clock build around a biaxial stepper motor
// ;P 2024 raphik
// Website: https://www.arduino.cc/en/Reference/Stepper
// Github: https://github.com/arduino-libraries/Stepper
#include <Stepper.h>
const int stepsPerRevolution = 200;
Stepper stepper1(stepsPerRevolution, 2, 3, 4, 5);
Stepper stepper2(stepsPerRevolution, 8, 9, 10, 11);
unsigned long oldSecondsMinuteHand = millis() / 1000;
unsigned long oldSecondsHourHand = oldSecondsMinuteHand;
unsigned long newSecondsMinuteHand = oldSecondsMinuteHand;
unsigned long newSecondsHourHand = oldSecondsHourHand;
// ambas saetas: 1 vuelta = 200 tics
// la saeta de los minutos: 3600 segundos = 200 tics
int secondsPerTicMinuteHand = 18; // = 3600 / 200
// la saeta de las horas: 43200 segundos = 200 tics
int secondsPerTicHourHand = 216; // = 43200 / 200
void setup() {
// aquí no hay nada que hacer
}
void loop() {
newSecondsMinuteHand = millis()/1000;
if ( newSecondsMinuteHand - oldSecondsMinuteHand >= ( secondsPerTicMinuteHand ) ) {
oldSecondsMinuteHand = newSecondsMinuteHand;
stepper1.step(1);
delay(5);
}
newSecondsHourHand = newSecondsMinuteHand;
if ( newSecondsHourHand - oldSecondsHourHand >= ( secondsPerTicHourHand ) ) {
oldSecondsHourHand = newSecondsHourHand;
stepper2.step(1);
delay(5);
}
}