Hi,
If you take a look at the code below, it works perfectly, even if buff[] is not declared static.
Why?
bool table[3][3] = {false, false, false,
false, false, false,
false, false, false};
bool readMonitor() {
char buf[3];
static byte i = 0;
if (Serial.available()>0){ buf[i] = Serial.read(); i++; }
if (int(buf[i-1]) == 13) {
i = 0;
table[buf[0]-48][buf[1]-48] = true;
return true;
}
return false;
}
void setup() {
Serial.begin(9600);
}
void loop() {
if (readMonitor()) {
for (int i = 0 ; i < 3 ; i++) {
for (int j = 0 ; j < 3 ; j++) Serial.print(table[i][j]);
Serial.println();
}
Serial.println();
}
}