help me please , is very important , please !!!!!!

Hello, i'm with a problem in a code , where it is showing an error , check for me as i can concert it ;

error: expected unqualified-id before 'if'

Code :

int led1 = 10; // Pino do Led

boolean status1 = false; // Verificar Status do led

void setup() {

Serial.begin(9600); //Inicializa a comunicação serial na velocidade 9600

pinMode(led1, OUTPUT); // Define o pino do led como de saida

digitalWrite(led1, LOW); // Inicia o led Desligado
}

void loop() {

char comando = Serial.read();

int chave1 = digitalRead(4);

if (chave1 == HIGH) { // Se a chave for precionada obter valor alto

if (status1) { // Verifica se o led esta ligado ou desligado de acordo com a variável boolean
// executa essa parte se ele estiver ligado
digitalWrite(led1, LOW); // led desligado
status1 = false; // Muda o status para falso para que a proxima vez ele indentifique como desligado
Serial.println("off"); // Envia a string para informar que o led foi desligado
} else {
// executa essa parte se ele estiver desligado
digitalWrite(led1, HIGH); // led ligado
status1 = true; // Muda o status para verdadeiro
Serial.println("on"); //enviar a string para informar que o led foi ligado
}
}
delay(250);
}

if (Serial.read == 'd') { //se a serial receber o caractere d
if (status1) {
digitalWrite(led1, LOW);
status1 = false
Serial.println("off");
}
}
if (Serial.read == 'a') { //se a serial receber o caractere a
if (status1) {
digitalWrite(led1, HIGH);
status1 = true
Serial.println("on");
}
}

Where does the function "loop()" end?

Welcome to the Forum. To get the most from this Forum, please read Nick Gammon's "How to" post at the top of the Forum, especially how to use code tags when posting source code here. Also, before your post your code, place the cursor in the source code window of the IDE and press Ctrl-T. This will reformat your code to a common C style. This also makes it easier for us to read. Often, it will catch the kinds of errors pointed out by AWOL.

I think after the first 'if', I do not understand very well. im from Brazil

Also, before your post your code, place the cursor in the source code window of the IDE and press Ctrl-T. This will reformat your code to a common C style.

It will do that if it can. If the number of { is not the same as the number of }, the tool will not reformat anything, but it WILL tell you that there is a problem.

I do not understand very well. im from Brazil

What does being from Brazil have to do with anything? I think you've just insulted a bunch of your country's citizens.

OK, every { should have a matching }.
Right after “void loop ()” there’s a {.
Which } do you think it matches?

I do not know, I should put q, I took the code on the Internet for a project

I took the code on the Internet for a project

When you copied it, you failed to get the last line, which would have been:

}

PaulS:
When you copied it, you failed to get the last line, which would have been:

}

it is missing one } ?

it is missing one } ?

At least one. Add one, and use Tools + Auto format. It will either properly indent your code or tell you there is another one missing.

PaulS:
At least one. Add one, and use Tools + Auto format. It will either properly indent your code or tell you there is another one missing.

did it and the error went on, I know that the error is in one of the 2 last fuções 'if'

Post your code, but this time use code tags, please.

Here's a spare pair you can have: [code][/code]

AWOL:
Post your code, but this time use code tags, please.

Here's a spare pair you can have: ``

LED1 int = 10; // Led pin

Status1 boolean = false; // Check LED status

void setup () {

  Serial.begin (9600); // Initialize the comunicaç࣠serial speed 9600

  pinMode (LED1, OUTPUT); // Set the LED pin as output

  digitalWrite (LED1, LOW); // Starts LED Off
}

void loop () {

  char command Serial.read = ();

  int key1 = digitalRead (4);

  if (key1 == HIGH) {// If the key is precionada get high value

    if (Status1) {// Check if the led is on or off according to variável boolean
      // Run this part if it is connected
      digitalWrite (LED1, LOW); // Led off
      Status1 = false; // Change to the false status so that the next time he indentifique to off
      Serial.println ( "off"); // Send the string to indicate that the LED is off
    } Else {
      // Run this part if it is off
      digitalWrite (LED1, HIGH); // LED connected
      Status1 = true; // Change the status to true
      Serial.println ( "on"); // Send the string to indicate that the LED was turned on
    }
  }
  delay (250);
}

if (Serial.read == 'd') {// if the serial receive d character
  if (Status1) {
    digitalWrite (LED1, LOW);
    Status1 = false
              Serial.println ( "off");
  }
}
if (Serial.read == 'a') {// if the serial receive the character to
  if (Status1) {
    digitalWrite (LED1, HIGH);
    Status1 = true
              Serial.println ( "on");
  }
}
    } Else {

I'm going to bet the compiler didn't like that.

Again, by my reading, "loop()" ends just after the "delay(250);"

Count your braces. Your loop function ends after the delay(250). The rest of the code is not in a function. That is illegal code and the source of your error.

In addition to the misplaced }

You missed out a couple of semicolons ;

here

status1 = false;

and here

status 1 = true;

In two places you have Serial.read where you should have Serial.read()

  char command Serial.read = ();

Have you EVER seen Serial.read() used this way?

You also have multiple serial reads. Which means that to check for the 'a', you need to send 3 characters or so.

After the fixing as indicated by PaulS, test the received command and do not do additional reads.

AWOL:

    } Else {

I'm going to bet the compiler didn't like that.

Again, by my reading, "loop()" ends just after the "delay(250);"

I put that after finishing the loop and delay? to start the rest of the code?