bonjour je débute dans la programmation et quand je veux verifier mon code il me met ce message d'erreur
a function-definition is not allowed here before '{' token
puis quand je retire les {}
il me met
expected initializer before 'randDelai'
en esperant que vous avez une solution
merci par avance
voici mon code
//variable
const int buttonPin = 2; // bouton numéro 1
const int buttonPin2 = 3; // bouton numéro 2
const int buttonPin3 = 4; // bouton numéro 3
const int ledPin = 13; //Bloc 1 led contour
const int ledPin1 = 12; //Bloc 2 led contour
const int ledPin2 = 11; //Bloc 3 led contour
const int ledPin3 = 10; //Bloc 4 led contour
const int ledPin4 = 9; //lettre B led
const int ledPin5 = 8; //lettre O led
const int ledPin6 = 7; //lettre O' led
const int ledPin7 = 6; //lettre M led
const int ledPin8 = 5; //DJ BOOM Animation led
int buttonState = 0;
int buttonState1 = 0;
int buttonState2 = 0;
int randDelai;
int randEtat;
void setup() {
// variable aléatoire
int attente()
{randDelai = random(20, 150);
return (randDelai)};
int etat()
{randEtat = random(0, 2);
return (randEtat)};
//adress
pinMode (2, INPUT);
pinMode (3, INPUT);
pinMode (13,OUTPUT);
pinMode (12,OUTPUT);
pinMode (11,OUTPUT);
pinMode (10,OUTPUT);
pinMode (9, OUTPUT);
pinMode (8, OUTPUT);
pinMode (7, OUTPUT);
pinMode (6, OUTPUT);
pinMode (5, OUTPUT);
}
void loop() {
buttonState = digitalRead(buttonPin);
buttonState1 = digitalRead(buttonPin2);
buttonState2 = digitalRead(buttonPin3);
if (buttonState == HIGH)
{
// LED on:
digitalWrite(ledPin, HIGH);
digitalWrite(ledPin1, HIGH);
digitalWrite(ledPin2, HIGH);
digitalWrite(ledPin3, HIGH);
digitalWrite(ledPin4, HIGH);
digitalWrite(ledPin5, HIGH);
digitalWrite(ledPin6, HIGH);
digitalWrite(ledPin7, HIGH);
digitalWrite(ledPin8, HIGH);
}
else if (buttonState1 == HIGH)
{
digitalWrite(ledPin, HIGH);
delay (1000);
digitalWrite(ledPin1, HIGH);
delay (1000);
digitalWrite(ledPin2, HIGH);
delay (1000);
digitalWrite(ledPin3, HIGH);
delay (1000);
digitalWrite(ledPin4, HIGH);
delay (1000);
digitalWrite(ledPin5, HIGH);
delay (1000);
digitalWrite(ledPin6, HIGH);
delay (1000);
digitalWrite(ledPin7, HIGH);
delay (1000);
digitalWrite(ledPin8, HIGH);
delay (1000);
digitalWrite(ledPin, LOW);
delay (1000);
digitalWrite(ledPin1, LOW);
delay (1000);
digitalWrite(ledPin2, LOW);
delay (1000);
digitalWrite(ledPin3, LOW);
delay (1000);
digitalWrite(ledPin4, LOW);
delay (1000);
digitalWrite(ledPin5, LOW);
delay (1000);
digitalWrite(ledPin6, LOW);
delay (1000);
digitalWrite(ledPin7, LOW);
delay (1000);
digitalWrite(ledPin8, LOW);
delay (1000);
}
else if (buttonState1 == HIGH)
{
digitalWrite(ledPin, etat()); // allumer la LED orange avec la valeur retournée par la fonction etat()
delay(attente()); // delai avec la valeur retournée par la fonction attente()
digitalWrite(ledPin1, etat());
delay(attente());
digitalWrite(ledPin2, etat());
delay(attente())
digitalWrite(ledPin3, etat());
delay(attente());
digitalWrite(ledPin4, etat());
delay(attente())
digitalWrite(ledPin5, etat());
delay(attente());
digitalWrite(ledPin6, etat());
delay(attente())
digitalWrite(ledPin7, etat());
delay(attente());
digitalWrite(ledPin8, etat());
delay(attente())
}
else
{
// LED off:
digitalWrite(ledPin, LOW);
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, LOW);
digitalWrite(ledPin3, LOW);
digitalWrite(ledPin4, LOW);
digitalWrite(ledPin5, LOW);
digitalWrite(ledPin6, LOW);
digitalWrite(ledPin7, LOW);
digitalWrite(ledPin8, LOW);
}
}
led_boom.ino (3.53 KB)