Expected unqualified-id

hi, can someone check this code and tell me what is wrong? the expected unqualified-id appears in the { Serial.begin under the int b = 0; (i´m still learning so this can be really wrong)

#include <SoftwareSerial.h>

SoftwareSerial bluetooth(2,3);
int ledPin = 13;

void setup(){
 pinMode(ledPin,OUTPUT);
 Serial.begin(9600);
 bluetooth.begin(9600);
}
void loop(){
 if(bluetooth.available()>0){
   char comando = bluetooth.read();

   if(comando == "1"){
     digitalWrite(ledPin,HIGH);
   }else if(comando == "0"){
     digitalWrite(ledPin,LOW);
   }
 }
}
int Microfono = 7;
int lecturaMicrofono = 0;
int Rele = 8;
int a = 0;
int b = 0;

{
 Serial.begin(9600);
 pinMode(Microfono, INPUT);
 pinMode(Rele,OUTPUT);
}
void loop()
{
 lecturaMicrofono= digitalRead(Microfono);
 if(lecturaMicrofono == HIGH)
 {
   a = a+1;
   b = 0;
   delay(200);
 }
if(a == 1 && b == 0)
{
 Serial.println("ENCENDIDO");
 digitalWrite(Rele,HIGH);
 b = 1;
}
if(a == 2)
{
 Serial.println("APAGADO");
 digitalWrite(Rele,LOW);
 a = 0;
}
}

You have more than one loop() function on your sketch and code not in a function

{
    Serial.begin(9600);
    pinMode(Microfono, INPUT);
    pinMode(Rele, OUTPUT);
}

You already began serial in your setup function. I do not see why you'd need to do so again. Try commenting it out or removing it.

Oops, looks like this is the union of more than one program.

How do i combine two Arduino sketches? - Software / Syntax & Programs - Arduino Forum

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