In the code below, I'm getting a compiling error
apc_21_timekeeper:15: error: 'clockUpdate' was not declared in this scope
TimedAction timer = TimedAction(1000,clockUpdate);
^
exit status 1
'clockUpdate' was not declared in this scope
I declared it later on in the code. Thanks for helping! New to coding and Arduino.
#include <SPI.h>
#include <DMD.h>
#include <TimerOne.h>
#include <TimedAction.h>
#include "SystemFont5x7.h"
#define DISPLAYS_ACROSS 1
#define DISPLAYS_DOWN 1
DMD dmd(DISPLAYS_ACROSS, DISPLAYS_DOWN);
String minsTens, minsUnits, secsTens, secsUnits;
int mins10, mins1, secs10, secs1;
int minutes, seconds;
int clockRunning = 0;
TimedAction timer = TimedAction(1000,clockUpdate);
void setup() {
timer.disable();
minutes = 0; seconds = 0;
pinMode(2, OUTPUT);
pinMode(A5, INPUT_PULLUP);
pinMode(A4, INPUT_PULLUP);
pinMode(A3, INPUT_PULLUP);
Timer1.initialize( 4000 ); //period in microseconds to call ScanDMD. Anything longer than 5000 (5ms) and you can see flicker.
Timer1.attachInterrupt( ScanDMD ); //attach the Timer1 interrupt to ScanDMD which goes to dmd.scanDisplayBySPI()
dmd.clearScreen( true ); //true is normal (all pixels off), false is negative (all pixels on)
dmd.selectFont(SystemFont5x7);
dmd.drawString(2,0,"TIME:",5,GRAPHICS_NORMAL);
dmd.drawString(8,8,"SET",5,GRAPHICS_NORMAL);
beep();
}
void loop() {
if (clockRunning == 0) {
if (digitalRead(A3) == 0) {
mins10++;
delay(200);
if (mins10 > 9) mins10 = 0;
minutes = mins10 * 10 + mins1;
displayUpdate();
}
if (digitalRead(A4) == 0) {
mins1++;
delay(200);
if (mins1 > 9) mins1 = 0;
minutes = mins10 * 10 + mins1;
displayUpdate();
}
}
if (digitalRead(A5) == 0) {
beep();
delay(200);
if (clockRunning == 0) {
timer.enable();
clockRunning = 1;
} else {
clockRunning = 0;
timer.disable();
dmd.drawString(2,8," OFF ",5,GRAPHICS_NORMAL);
delay(3000);
displayUpdate();
}
}
if (clockRunning == 1) timer.check();
}
void ScanDMD() {
dmd.scanDisplayBySPI();
}
void clockUpdate() {
seconds--;
if (seconds < 0) {
seconds = 59;
minutes--;
}
secs10 = seconds / 10;
secs1 = seconds % 10;
mins10 = minutes / 10;
mins1 = minutes % 10;
displayUpdate();
if (minutes == 0 && seconds == 0) {
dmd.clearScreen(true);
dmd.drawString(5,0,"FULL",4,GRAPHICS_NORMAL);
dmd.drawString(5,8,"TIME",4,GRAPHICS_NORMAL);
timer.disable();
digitalWrite(2, HIGH);
}
}
void displayUpdate() {
minsTens = (String)mins10;
minsUnits = (String)mins1;
secsTens = (String)secs10;
secsUnits = (String)secs1;
dmd.drawString(2,8,minsTens.c_str(),1,GRAPHICS_NORMAL);
dmd.drawString(8,8,minsUnits.c_str(),1,GRAPHICS_NORMAL);
dmd.drawString(14,8,":",1,GRAPHICS_NORMAL);
dmd.drawString(19,8,secsTens.c_str(),1,GRAPHICS_NORMAL);
dmd.drawString(25,8,secsUnits.c_str(),1,GRAPHICS_NORMAL);
}
void beep() {
digitalWrite(2, HIGH);
delay(30);
digitalWrite(2, LOW);
}