# \[SOLVED\] 'expected unqualified-id before 'else'' troubleshooting help needed

**URL:** <https://forum.arduino.cc/t/solved-expected-unqualified-id-before-else-troubleshooting-help-needed/923169>\
**Category:** Programming\
**Created:** [November 9, 2021, 6:25am UTC](https://forum.arduino.cc/t/solved-expected-unqualified-id-before-else-troubleshooting-help-needed/923169 "2021-11-09T06:25:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![itsethan](https://avatars.discourse-cdn.com/v4/letter/i/d2c977/32.png) [@itsethan](https://forum.arduino.cc/u/itsethan)\
**Post date:** [November 9, 2021, 6:25am UTC](https://forum.arduino.cc/t/solved-expected-unqualified-id-before-else-troubleshooting-help-needed/923169/1 "2021-11-09T06:25:01Z")

</div>

I was writing some code, the code worked perfectly fine before but now the sketchwill not compile because of the error message 'expected unqualified-id before 'else''. Here is my code and the error is on line 216

//rgb led, lock, matrix, lcd, RFID

#include \<SPI.h\> // SPI library  
#include \<MFRC522.h\> // RFID library  
#include \<FastLED.h\> //RGB LED Library  
#include \<Keypad.h\> //Matrix library  
#include \<LiquidCrystal.h\> //LCD library  
#define LOCK 12

//RGB LED stuff  
#define LED 13  
#define NUM\_LED 8  
CRGB led[NUM\_LED];  
#define LED\_TYPE WS2811 //RGB led model

//matrix stuff  
const int ROW\_NUM = 4; //four rows  
const int COLUMN\_NUM = 3; //three columns

char keys[ROW\_NUM][COLUMN\_NUM] = {  
{'1', '2', '3'},  
{'4', '5', '6'},  
{'7', '8', '9'},  
{'\*', '0', '#'}  
};

byte pin\_rows[ROW\_NUM] = {11, 10, 9, 8};  
byte pin\_column[COLUMN\_NUM] = {7, 6, 5};

Keypad keypad = Keypad( makeKeymap(keys), pin\_rows, pin\_column, ROW\_NUM, COLUMN\_NUM );

const String password = "1234"; // change your password here  
String input\_password;

// initialize the library by associating any needed LCD interface pin  
// with the arduino pin number it is connected to

//LCD stuff  
const int rs = 4, en = 3, d4 = 22, d5 = 24, d6 = 26, d7 = 28;  
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

//RFID stuff

/\*  
Pins SPI UNO Mega2560 Leonardo  
1 (NSS) SAD (SS) 10 53 10  
2 SCK 13 52 SCK1  
3 MOSI 11 51 MOSI1  
4 MISO 12 50 MISO1  
5 IRQ \* \* \*  
6 GND GND GND GND  
7 RST 9 ? Reset  
8 +3.3V (VCC) 3V3 3V3 3.3V  
Not needed  
1 on ICPS header  
\*/

const int pinRST = 2;  
const int pinSDA = 53;  
MFRC522 mfrc522(pinSDA, pinRST); // Set up mfrc522 on the Arduino

void setup() {  
SPI.begin(); // open SPI connection  
mfrc522.PCD\_Init(); // Initialize Proximity Coupling Device (PCD)  
Serial.begin(9600);

pinMode(LOCK, OUTPUT);  
pinMode(LED, OUTPUT);

FastLED.addLeds\<LED\_TYPE, LED, GRB\>(led, NUM\_LED);

input\_password.reserve(32);

FastLED.clear();

fill\_solid(led, NUM\_LED, CRGB::Blue);

FastLED.show();

// set up the LCD's number of columns and rows:  
lcd.begin(16, 2);  
// Print a message to the LCD.  
lcd.print("safe ready");  
}

void loop() {

char key = keypad.getKey();

if (key) {  
Serial.println(key);

```
if (key == '*') {
  input_password = "";
  lcd.clear();
  delay(10);
  lcd.print("cleared!");
  FastLED.clear();
  fill_solid(led, NUM_LED, CRGB::Blue);
  FastLED.show();

} else if (key == '#') {
  if (password == input_password) {
    lcd.clear();
    lcd.print("Unlocked!");
    Serial.println("password is correct");
    FastLED.clear();
    fill_solid(led, NUM_LED, CRGB::Green);
    FastLED.show();
    digitalWrite(LOCK, HIGH);
    delay(5000);

    FastLED.clear();
    fill_solid(led, NUM_LED, CRGB::Blue);
    FastLED.show();
    digitalWrite(LOCK, LOW);

  }
  else {
    Serial.println("password is incorrect, try again");
    FastLED.clear();
    fill_solid(led, NUM_LED, CRGB::Red);
    FastLED.show();
    lcd.clear();
    lcd.print("incorrect password!");
    // digitalWrite(LOCK,LOW); (already low)
    //when password is incorrect

    delay(5000);

    FastLED.clear();

    fill_solid(led, NUM_LED, CRGB::Blue);

    FastLED.show();

  }
} /* else {
   // Serial.println("password being filled out");

    FastLED.clear();

```

fill\_solid(led, NUM\_LED, CRGB::Blue);

FastLED.show();

```
    // when password is being filled out */

```

}

input\_password = "";  
} else {  
input\_password += key;  
// digitalWrite(LOCK,LOW);

// when password is cleared  
/\* FastLED.clear();

```
fill_solid(led, NUM_LED, CRGB::Red);

FastLED.show();

```

\*/

}  
//RFID code  
// Look for new cards  
if ( ! mfrc522.PICC\_IsNewCardPresent())  
{  
return;  
}  
// Select one of the cards  
if ( ! mfrc522.PICC\_ReadCardSerial())  
{  
return;  
}  
//Show UID on serial monitor  
Serial.print("UID tag :");  
String content = "";  
byte letter;  
for (byte i = 0; i \< mfrc522.uid.size; i++)  
{  
Serial.print(mfrc522.uid.uidByte[i] \< 0x10 ? " 0" : " ");  
Serial.print(mfrc522.uid.uidByte[i], HEX);  
content.concat(String(mfrc522.uid.uidByte[i] \< 0x10 ? " 0" : " "));  
content.concat(String(mfrc522.uid.uidByte[i], HEX));  
}  
Serial.println();  
Serial.print("Message : ");  
content.toUpperCase();  
if (content.substring(1) == "53 1F C1 18") //change here the UID of the card/cards that you want to give access  
{  
/\* Serial.println("Authorized access, white card");  
Serial.println();  
delay(500); \*/  
lcd.clear();  
lcd.print("Unlocked!");  
FastLED.clear();  
fill\_solid(led, NUM\_LED, CRGB::Green);  
FastLED.show();  
digitalWrite(LOCK, HIGH);

delay (5000);  
lcd.clear();  
lcd.print("Safe ready!");  
FastLED.clear();  
fill\_solid(led, NUM\_LED, CRGB::Blue);  
FastLED.show();  
digitalWrite(LOCK, LOW);

}  
else {  
Serial.println(" Access denied");  
Serial.println();  
delay(500);  
lcd.clear();  
lcd.print("wrong tag");  
FastLED.clear();  
fill\_solid(led, NUM\_LED, CRGB::Red);  
FastLED.show();  
digitalWrite(LOCK, LOW);

delay(10000);  
lcd.clear();  
lcd.print("safe ready!");  
FastLED.clear();  
fill\_solid(led, NUM\_LED, CRGB::Blue);  
FastLED.show();

}

---

<div class="post-metadata">

**Author:** ![itsethan](https://avatars.discourse-cdn.com/v4/letter/i/d2c977/32.png) [@itsethan](https://forum.arduino.cc/u/itsethan)\
**Post date:** [November 9, 2021, 6:35am UTC](https://forum.arduino.cc/t/solved-expected-unqualified-id-before-else-troubleshooting-help-needed/923169/2 "2021-11-09T06:35:06Z")

</div>

never mind everyone, it is a weird error messages but I had my } in the wrong spot so there was no end to the void loop, thanks

---

<div class="post-metadata">

**Author:** ![red\_car](https://avatars.discourse-cdn.com/v4/letter/r/b77776/32.png) [@red\_car](https://forum.arduino.cc/u/red_car)\
**Post date:** [November 9, 2021, 6:44am UTC](https://forum.arduino.cc/t/solved-expected-unqualified-id-before-else-troubleshooting-help-needed/923169/3 "2021-11-09T06:44:35Z")

</div>

You would find these types of issue easier if you indented your code. Cntl-T.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 8, 2022, 6:44am UTC](https://forum.arduino.cc/t/solved-expected-unqualified-id-before-else-troubleshooting-help-needed/923169/4 "2022-05-08T06:44:48Z")

</div>

Closed on May 8, 2022, 6:44am UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
