I have designed and printed a stepper driven clock and have the following issue.
This section of code works fine.
The second hand advances every second and if i press my 'advance button' the clock moves forwards by one minute.
void MOVE_TIME() {
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
readDS3231time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
ss = second;
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
for ( int count = 1; count <= 9600; count++) {
digitalWrite(Y_DIR_PIN , LOW);
digitalWrite(Y_STEP_PIN , HIGH);
delay(1);
digitalWrite(Y_STEP_PIN , LOW);
}
}
if (ss != ssold) { //ONLY CONTINUE IF THE SECONDS HAVE CHANGED
for ( int count = 1; count <= 160; count++) { //forwards CW
digitalWrite(Y_DIR_PIN , LOW);
digitalWrite(Y_STEP_PIN , HIGH);
delay(Y_SPEED);
digitalWrite(Y_STEP_PIN , LOW);
}
ssold = ss;
}
}
My question is, why will the advance button NOT work if i use the following code?
void MOVE_TIME() {
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
readDS3231time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
ss = second;
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
advance_time;
}
if (ss != ssold) { //ONLY CONTINUE IF THE SECONDS HAVE CHANGED
for ( int count = 1; count <= 160; count++) { //forwards CW
digitalWrite(Y_DIR_PIN , LOW);
digitalWrite(Y_STEP_PIN , HIGH);
delay(Y_SPEED);
digitalWrite(Y_STEP_PIN , LOW);
}
ssold = ss;
}
}
void advance_time() {
for ( int count = 1; count <= 3200; count++) {
digitalWrite(Y_DIR_PIN , LOW);
digitalWrite(Y_STEP_PIN , HIGH);
delay(1);
digitalWrite(Y_STEP_PIN , LOW);
}
}
When the button is pressed it will not run the advance_time routine