Hi all
I found a piece of code on this thread http://arduino.cc/forum/index.php/topic,48847.0.html that looked like just what I wanted but I can’t get the ‘check correct sequence’ part to work (I’m assuming that it’s working ok up to the error messages).
Here’s what I have (the part that is throwing the error - I can post the full sketch if needed, it’s not huge):
// To check the code is correct
char secret[4] = { ‘6’,‘7’,‘8’,‘9’};
byte cnt=0;
for (byte ix=0; ix<sizeof(secret); ix++) {
if (codearray[(charindex-sizeof(secret)+ix)%sizeof(codearray)] == secret[ix]) cnt++;
}
if (cnt == sizeof(secret)) {
digitalWrite(greenLed, HIGH); // set Green LED ON
delay(250); // wait for 0.25 seconds
digitalWrite(greenLed, LOW); // set Green LED OFF
}
else {
if (codeTries == 0) {
digitalWrite(redLed, LOW); // set Red LED ON
delay(250); // wait for 0.25 seconds
digitalWrite(redLed, HIGH); // set Red LED OFF
}
codeTries = codeTries - 1
}
The error messages that are produced are:
_4DigitWIP:52: error: expected unqualified-id before ‘for’
_4DigitWIP:52: error: expected constructor, destructor, or type conversion before ‘<’ token
_4DigitWIP:52: error: expected constructor, destructor, or type conversion before ‘++’ token
_4DigitWIP:56: error: expected unqualified-id before ‘if’
_4DigitWIP:62: error: expected unqualified-id before ‘else’
Can somebody help me out and explain what “expected unqualified-id” and “expected constructor, destructor, or type conversion” mean in simple terms? I have tried searching for answers but didn’t find anything helpful.
Basically it is supposed to check that the code entered from the keypad matches the “secret code” and allows three attempts (I set ’ int codeTries = 2; ’ at the beginning) to get it right before going to the “Failed” state where it flashes the Red LED. Each attempt should flash the Green LED - the two LEDs are supposed to be ‘reversed’ before anybody picks up on it and I have declared them at the begiining of the code.
The error messages are extremely unhelpful for us newbies. Somebody ought to write a guide “Arduino Error Messages Explained” - I’d pay good money for that just at the moment (less than a week from getting my Uno and having no previous programming experience)…
Thanks
Duncan