Hi,
I'm using a 7-segment display to have a 60 minutes countdown clock in a game. If the player makes an error, they get a time penalty (straftijd) where the time will run down a few minutes extra fast (3 minutes in a few seconds).
I've made a code which is exactly the same as the code to run the clock on normal speed (with delay 1000 per second). Now i have reduced and/or even removed the delay during the timepenalty. The original code was on an arduino Uno. Now i am running it on a Mega but the countdown clock isn't going as fast.... It takes about 10 seconds to give a 3 minutes time panelty. On an Uno it takes about 3 seconds)
I've isolated the code for the timepenalty to run in on an Mega and it is going to slow.
Any idea why this is slower than on an Uno?
And any idea how to make this faster (about 3 or 4 times faster atleast)
#include "SevenSegmentTM1637.h"
#include "SevenSegmentExtended.h"
const byte PIN_CLK = 9;
const byte PIN_DIO = 13;
SevenSegmentExtended display(PIN_CLK, PIN_DIO);
void setup() {
display.begin();
display.setBacklight(100);
}
void loop() {
byte straftijd = 180;
byte hours = 60;
byte minutes = 00;
for ( ; straftijd > 0 ;) {
for ( ; hours > 0 ; ) {
for ( ; minutes > 0; minutes-- && straftijd--) {
display.printTime(hours, minutes, true);
if (straftijd == 0) {
return;
}
};
if (straftijd > 0) {
minutes = 00;
display.printTime(hours, minutes, true); //print seconde 00
hours--;
minutes = 59;
}
}
}
}