Problem in compiling help!

#include <Keypad.h>
#define LED 13
#define LED 12;
int buzzer = 9;

const byte ROWS = 4; //quattro righe
const byte COLS = 3; //tre colonne
char keyInsert[6];
int i = 0;
int j = 0;
int s = 0;
int x = 0;
char code[7]= "112233";
}
char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'},
};
}
byte rowPins[ROWS] = {8,7,6,5}; 
byte colPins[COLS] = {4,3,2}; 
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
}
void setup(){
  Serial.begin(9600);
  pinMode(13,OUTPUT);
  pinMode(12,OUTPUT);
  pinMode(buzzer, OUTPUT);
  const int buttonPin = 1; 
int buttonState = 0; 
}
}
 
void loop(){
  char key = keypad.getKey();   
  if (i==0);
    Serial.println("Insert PIN to verify...");
    i++;
  }
  }
  if (key != NO_KEY && j<6){
    Serial.print("*");
    keyInsert[j]=key;
    j++;
  }
  }
   if(key == '*') {
      Serial.println();
      Serial.println("Verifyng the code...");
      delay(100);
    
      for(s=0; s<6;s++);
        if(keyInsert[s]==code[s]);
          x++;       
      }
      }
     
      if(x==6){
      Serial.println("The code is correct"); 
      digitalWrite(13,HIGH);
      digitalWrite(9,HIGH);
      delay(20);
      digitalWrite(9,LOW);
      delay(200);
    }      
    digitalWrite(13,LOW); 
  } 
  }

      else{
         Serial.println("The code is incorrect, please retry");
         digitalWrite(12,HIGH);
         delay(200);
         x=0;
         i=0;
         j=0;
         digitalWrite(12,LOW);
       }
       }
        
    if(key == '#'){
        x=0;
        i=0;
        j=0;
     
    }    
}

Arduino:1.6.1 (Windows 8.1), Scheda:"Arduino Uno"

Serratura.ino:14:1: error: expected declaration before '}' token

Errore durante la compilazione

what am I doing wrong?

expected declaration before '}' token

You have not got a '{' before you have the '}'

I can not see why you have a closing brace at that point in the code anyway.

char code[7]= "112233";
}
char keys[ROWS][COLS] = {

what am I doing wrong?

Putting a closing brace where there shouldn't be one, and in several other places too.

In fact the entire code is riddled with extra closing braces, did you write this?

You might have fallen victim to the new feature of the IDE, that is when you type something with an opening brace, and then hit return the IDE automatically fills in the closing brace for you, you seem to be typing an extra one.

#define LED 12;

No semicolon should be at the end of a #define

Why have you added curly brackets in heaps of places where they're not needed?
Even when declaring variables, like here:-

char code[7] = "112233";
}
char keys[ROWS][COLS] =

And in heaps of other places throughout your code.
If you click on >Tools >Auto Format, they immediately become obvious.

As near as I can tell, this is what you intended to write.
Check it over, though, because I might be wrong. I'm not too good at reading minds. :slight_smile:

#include <Keypad.h>
#define LED 13
#define LED 12;
int buzzer = 9;

const byte ROWS = 4; //quattro righe
const byte COLS = 3; //tre colonne
char keyInsert[6];
int i = 0;
int j = 0;
int s = 0;
int x = 0;
char code[7] = "112233";

char keys[ROWS][COLS] =
{
    {'1', '2', '3'},
    {'4', '5', '6'},
    {'7', '8', '9'},
    {'*', '0', '#'},
};

byte rowPins[ROWS] = {8, 7, 6, 5};
byte colPins[COLS] = {4, 3, 2};
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup()
{
    Serial.begin(9600);
    pinMode(13, OUTPUT);
    pinMode(12, OUTPUT);
    pinMode(buzzer, OUTPUT);
    const int buttonPin = 1;
    int buttonState = 0;
}

void loop()
{
    char key = keypad.getKey();
    if (i == 0);
    Serial.println("Insert PIN to verify...");
    i++;

    if (key != NO_KEY && j < 6)
    {
        Serial.print("*");
        keyInsert[j] = key;
        j++;
    }

    if (key == '*')
    {
        Serial.println();
        Serial.println("Verifyng the code...");
        delay(100);

        for (s = 0; s < 6; s++);
        if (keyInsert[s] == code[s]);
        x++;
    }

    if (x == 6)
    {
        Serial.println("The code is correct");
        digitalWrite(13, HIGH);
        digitalWrite(9, HIGH);
        delay(20);
        digitalWrite(9, LOW);
        delay(200);
        digitalWrite(13, LOW);
    }
    else
    {
        Serial.println("The code is incorrect, please retry");
        digitalWrite(12, HIGH);
        delay(200);
        x = 0;
        i = 0;
        j = 0;
        digitalWrite(12, LOW);
    }

    if (key == '#')
    {
        x = 0;
        i = 0;
        j = 0;
    }
}

I see that others have also pointed out the problem, but since I went to the trouble of correcting it.....

Nope, there are still more errors, like this:-

        for (s = 0; s < 6; s++);
        if (keyInsert[s] == code[s]);
        x++;
    }

Go right over it again. I've spent enough time messing with this (mess).

I did that and got down to the else about 10 lines from the end and I couldn't decide what if it belonged to so I gave up.

Grumpy_Mike:
I did that and got down to the else about 10 lines from the end and I couldn't decide what if it belonged to so I gave up.

Yeah, I know what you mean. I just quickly went through ripping out brackets until it compiled. Didn't notice those last errors until afterwards, and by then I was already sick of it. :slight_smile:
Looking at it again, there's another one of those, at the beginning of 'loop()':-

if (i == 0);
    Serial.println("Insert PIN to verify...");
    i++;