ok, ive done what you said, but when i verify the code i keep on getting the error: expected ']' before ';' token.
#define BTNCNT 9;
#define ATTCNT 2;
int a = 0; //set a
int y = 0; // Set y
int x = 0; // Set x
int ledOne = 13; //Set Red LED
int ledTwo = 12; //Set Green LED
byte buttons[BTNCNT] = {2,3,4,5,6,7,8,9,10}; //Set buttons to array
byte pass[ATTCNT] = {2,3}; // Set password
byte attempt[ATTCNT]; // Set attempts array
byte state[ATTCNT]; // Make states array
byte oldstate[ATTCNT]; // When button is hit, info added here
int time = 0;
void setup(){
pinMode(ledOne, OUTPUT);
pinMode(ledTwo, OUTPUT);
for(x=0; x<BTNCNT; x++){
pinMode(buttons[x], INPUT);
}
digitalWrite(ledOne, HIGH);
}
void loop(){
for(x=0; x<BTCNT; x++){
state[x] = digitalRead(buttons[x]); // Check states of each button
}
if(attempt[0] != pass[0]){
TimeOut();
}
for(x=0; x<BTNCNT; x++){
if(oldstate[x] != state[x]){ //If these new states are different then the old ones
if(state[x] == HIGH)
{
attempt[y] = buttons[x]; //Set attempt (Just first index for now) to buttons pressed
y++;
time = millis();
}
}
}
for(x=0; x<ATTCNT; x++){
if(attempt[0] == pass[0]){
Correct();
}
}
if ((millis() - time) > 10000){
for(x=0;x<ATTCNT;x++){
attempt[x] = 0;
y=0;
}
}
if(y > 3){
for(x=0;x<ATTCNT;x++){
attempt[x] = 0;
}
y=0;
}
for(x=0;x<BTNCNT;x++){
oldstate[x] = state[x];
}
}
void Correct(){
digitalWrite(ledOne, LOW);
digitalWrite(ledTwo, HIGH);
}
void TimeOut(){
digitalWrite(ledTwo, LOW);
digitalWrite(ledOne, HIGH);
}
can you try and verify, because i cant see whats wrong