coding error

here's my code :

int LEDS = 5;
int buttonA = 9;
int buttonB = 8;
byte leds = 0;
void setup()
{
pinMode(LEDS, OUTPUT);
pinMode(buttonA, INPUT_PULLUP);
pinMode(buttonB, INPUT_PULLUP);
Serial.begin(6900);              
}
void loop()
{
if (digitalRead(buttonA) == LOW)
{
digitalWrite(LEDS,HIGH);
}
if (digitalRead(buttonB) == LOW)
{
digitalWrite(LEDS, LOW);
}
else 
digitalWrite(LEDS, HIGH);
delay(500);
digitalWrite(LEDS, LOW);
delay(500);
}
}

my error :

28:1: error: expected declaration before '}' token

thanks![/code]

Do a Tools > Auto Format on your code and then check the automatic indentation to make sure it matches your intended program structure.

(deleted)

pert:
Do a Tools > Auto Format on your code and then check the automatic indentation to make sure it matches your intended program structure.

It is pointless to suggest using Tools + Auto Format, when there is clearly mis-matched curly braces. Tools + Autp Format won't work when the number of { and the number of } are not equal.

I see you say that often but I've never had that problem. Auto Format works fine for me on Windows with every IDE version I can remember using no matter how mismatched the braces are. Maybe it's an OS-specific thing? I can't imagine why that would matter

Here's mannan12's code after I did an Auto Format on it:

int LEDS = 5;
int buttonA = 9;
int buttonB = 8;
byte leds = 0;
void setup()
{
  pinMode(LEDS, OUTPUT);
  pinMode(buttonA, INPUT_PULLUP);
  pinMode(buttonB, INPUT_PULLUP);
  Serial.begin(6900);
}
void loop()
{
  if (digitalRead(buttonA) == LOW)
  {
    digitalWrite(LEDS, HIGH);
  }
  if (digitalRead(buttonB) == LOW)
  {
    digitalWrite(LEDS, LOW);
  }
  else
    digitalWrite(LEDS, HIGH);
  delay(500);
  digitalWrite(LEDS, LOW);
  delay(500);
}
}

As you can see, the cause of the error is now much more obvious.

PaulS:
It is pointless to suggest using Tools + Auto Format, when there is clearly mis-matched curly braces. Tools + Autp Format won't work when the number of { and the number of } are not equal.

Auto Format works just as well when the number of { and the number of } are not equal. Whilst it will not (cannot) correct the error, it makes the fact that there are missing or extra brackets/braces more obvious.

I see you say that often but I've never had that problem.

The IDE has been improved, then. It used to just post a red bar with "Auto Format Cancelled. Too many xxxx curly braces", where xxxx was left or right. I'll stop mentioning the issue, then.

Actually that would a helpful message for beginners, though I wouldn't trade it for auto formatting. Maybe it was a limitation of older versions of the AStyle program the Arduino IDE uses for Auto Format.