I created a code and there is an error, can you help me?

CAN YOU HELP ME ?

(On "ARDUINO UNO")

real question:
J'ai crée un code et il y a une erreur pouvez vous m'aider ?

The error message says:

Compilation error: a function-definition is not allowed here before '{' token

Here is the code:

#define LED 13
#define LED1 12
#define LED2 11
#define BUTTON 10


const int ledPin = 9;


int buttonState = 0;


void setup() {
 Serial.begin(9600);
 pinMode(13, OUTPUT);
 pinMode(12, OUTPUT);
 pinMode(11, OUTPUT);
 pinMode(ledPin, OUTPUT);
 pinMode(10, INPUT);
}

void loop() {
  digitalWrite (LED, HIGH);
  Serial.println("LED R ALUMEE");
  delay (5000);
  digitalWrite (LED, LOW);
  Serial.println("LED R ETEINTE");
  digitalWrite (LED1, HIGH);
  Serial.println("LED V ALUMEE");
  delay (5000);
  digitalWrite (LED1, LOW);
  Serial.println("LED V ETEINTE");
  digitalWrite (LED2, HIGH);
  Serial.println("LED G ALUMEE");
  delay (2000);
  digitalWrite (LED2, LOW);
  Serial.println("LED G ETEINTE");
  if(buttonState == HIGH) {
   void loop (){          //it's here
    digitalWrite(ledPin, HIGH);
    }
   }
  }

Thanks in advance :grin:


  if(buttonState == HIGH) {
   void loop (){          //it's here
    digitalWrite(ledPin, HIGH);
    }
   }

This is wrong.

Why do you have a (second) definition of loop() inside the if in loop()?

Hmm, @LarryD is faster :+1:

I didn't understand

you appear to be defining function loop() twice in lines 22 and 39

try removing line 39

void loop (){          //it's here

Good morning
Duplicate post with this one:

Can a moderator close this topic, knowing that the solution was provided in the French category topic?

@dariusistoc1 Read Les bonnes pratiques du forum francophone and apply them. In particular, do not create duplicate topics.

Thanks in advance :slight_smile:
Friendships
Remi