Kaph:
Now this works absolutely fine. But say I wanted it to remain on for 500ms, then display nothing -grid(0,0,0,0,0,0,0,0)-, for 500ms, how would I do this?
First define the 'tick' rate of your program (eg. 500ms). Now use the function 'millis()' to update at that rate:
// What to display...
bool displayBlank = false;
void loop()
{
// Will go 'true' on a program tick
bool tick = false;
// Program timing happens here
static unsigned long prevTime=0;
unsigned long elapsed = millis()-prevTime;
if (elapsed > 500) {
tick = true;
prevTime += 500;
}
// 'tick' indicates we need an update
if (tick) {
// Do something, eg. switch between blank/not blank...
displayBlank = !displayBlank;
}
// Refresh the display
if (displayBlank) {
grid(0,0,0,0,0,0,0,0);
}
else {
grid(255,231,231,129,129,231,231,255);
}
}
This avoids locking up the CPU so you can keep your display running.