CrossRoads:
You've not set up the code sections properly. This should compile.
unsigned long currentMicros;
unsigned long previousMicros;
unsigned long elapsedTime;
byte hundredths;
byte tenths;
byte secondsOnes = 0;
byte oldsecondsOnes;
byte secondsTens = 0;
byte minutesOnes = 0;
byte minutesTens = 0;
byte hoursOnes= 0;
byte hoursTens = 1;
byte fontArray[] = {
0b00111111, // 0 1 = segment on, DP-g-f-e-d-c-b-a
0b00000110, // 1
0b01011011, // 2
0b01001111, // 3
0b01100110, // 4
0b01101101, // 5
0b01111100, // 6
0b00000111, // 7
0b01111111, // 8
0b01101111, // 9
0b00000000, // blank
0b10000000, // DP
};
// a
// f b
// g
// e c
// d DP
void setup(){
Serial.begin(115200); // make serial monitor match
Serial.println ("Setup Done"); // " was missing
}
void loop(){
currentMicros = micros();
// how long's it been?
elapsedTime = currentMicros - previousMicros;
if ( elapsedTime >=10000UL){ // 0.01 second passed? Update the timers
previousMicros = previousMicros + 10000UL;
hundredths = hundredths+1;
if (hundredths == 10){
hundredths = 0;
tenths = tenths +1;
if (tenths == 10){
tenths = 0;
secondsOnes = secondsOnes + 1;
if (secondsOnes == 10){
secondsOnes = 0;
secondsTens = secondsTens +1;
if (secondsTens == 6){
secondsTens = 0;
minutesOnes = minutesOnes + 1;
if (minutesOnes == 10){
minutesOnes = 0;
minutesTens = minutesTens +1;
if (minutesTens == 6){
minutesTens = 0;
hoursOnes = hoursOnes + 1;
if (hoursOnes == 10){
hoursOnes = 0;
hoursTens = hoursTens +1;
if ( (hoursTens == 2) && (hoursOnes == 4){
hoursOnes = 0;
hoursTens = 0;
if (days>1){
days = days-1;
}
else {
days = 365;
years = years - 1;
}
} // 24 hr rollover check
} //hoursTens rollover check
} // hoursOnes rollover check
} // minutesTens rollover check
} // minutesOnes rollover check
} // secondsTens rollover check
} // secondsOnes rollover check
} // tenths rollover check
} // hundredths rollover check
} // hundredths passing check
if (oldSecondsOnes != secondsOnes){ // show the elapsed time once a second
oldSecondsOnes = secondsOnes;
} // end one second check
// code to drive 7 segment display will go here.
} // end loop
I tool out the display code for the 7 segment display.
What are you using, and how are they wired up?
we are using the Arduino Mega, and the wiring is this.
#define A 22 // the wires go from the respective pin [in this case pin 22] to the led
#define B 23 //pin 23 to 1st 7 segment display, light B
#define C 24 //pin 24 1st seven segment display, light C
#define D 25 //pin 25
#define E 26 //pin 26
#define F1 27
#define G 28
#define AA 29
#define B2 30
#define C2 31
#define D2 32
#define E2 33
#define F2 34
#define G2 35
#define AB 36
#define B3 37
#define C3 38
#define D3 39
#define E3 40
#define F3 41
#define G3 42
#define AC 43
#define B4 44
#define C4 45
#define D4 46
#define E4 47
#define F4 48
#define G4 49
#define DP 50 //pin 50
is there a way to do the rest of the coding so that it works with this wiring? or do we need to do a different wiring system, and if so what is it?
here are two pictures of the setup as well
Image 1
Image 2