Arduino, erreur dans le code, URGENT !

Résolu/Fermé
Antoinep52 - 30 janv. 2015 à 20:45
NHenry Messages postés 15162 Date d'inscription vendredi 14 mars 2003 Statut Modérateur Dernière intervention 24 octobre 2024 - 30 janv. 2015 à 23:19
bonjours, je suis en, train de coder mon arduin mega 2560 apres 1h de montage matériel, voici le code que je viens de realiser pour, le probleme, c'est que je ne sais pas ou se trouve mes erreures :/ voici mon code et les erreures:

LE CODE:
  int btnbas;
  int btngauche;
  int btndroite;
  int auto;

void setup() {
  pinMode(53, OUTPUT); // blue 2
  pinMode(22, OUTPUT); // blue 2
  pinMode(33,OUTPUT); // green
  pinMode(2,OUTPUT); // white
  pinMode(35,INPUT); // btnbas
  pinMode(5,OUTPUT); // red
  pinMode(10,OUTPUT); // bip
  pinMode(31,INPUT); // btndroite
  pinMode(29,INPUT); // btngauche
}

void loop(){

  btnbas = 0;
  btngauche = 0;
  btndroite = 0;
  auto = 0;
  
          digitalWrite(22,HIGH);
          digitalWrite(53,HIGH);
          delay(200);
          digitalWrite(53,LOW); // blue 2
          digitalWrite(22,LOW); // blue 2
          digitalWrite(33,LOW); // green
          digitalWrite(2,LOW); // white
          digitalWrite(5,LOW); // red
          digitalWrite(10,LOW); // bip
          
          delay(200);
          digitalWrite(10,HIGH);
          delay(200);
          digitalWrite(10,LOW);
          
          delay(2000);
          
          delay(200);
          digitalWrite(10,HIGH);
          delay(200);
          digitalWrite(10,LOW);
          
          digitalWrite(5,HIGH);
          delay(1000);
          digitalWrite(5,LOW);
          delay(1000);
          digitalWrite(5,HIGH);
          delay(1000);
          digitalWrite(5,LOW);
          delay(1000);
          digitalWrite(5,HIGH);
          delay(1000);
          digitalWrite(5,LOW);
          delay(1000);
          digitalWrite(5,HIGH);
          delay(1000);
          digitalWrite(5,LOW);
          delay(1000);
          digitalWrite(5,HIGH);
          delay(1000);
          digitalWrite(5,LOW);
          delay(1000);
          digitalWrite(5,HIGH);
          delay(1000);
          digitalWrite(5,LOW);
          delay(1000);
          digitalWrite(33,HIGH);
  
  if(digitalRead(32)==btnbas){
          digitalWrite(53,LOW); // blue 2
          digitalWrite(22,LOW); // blue 2
          digitalWrite(33,LOW); // green
          digitalWrite(2,LOW); // white
          digitalWrite(5,LOW); // red
          digitalWrite(10,LOW); // bip
          
          delay(200);
          digitalWrite(10,HIGH);
          delay(200);
          digitalWrite(10,LOW);
          
          delay(2000);
          
          delay(200);
          digitalWrite(10,HIGH);
          delay(200);
          digitalWrite(10,LOW);
          
          digitalWrite(5,HIGH);
          delay(1000);
          digitalWrite(5,LOW);
          delay(1000);
          digitalWrite(5,HIGH);
          delay(1000);
          digitalWrite(5,LOW);
          delay(1000);
          digitalWrite(5,HIGH);
          delay(1000);
          digitalWrite(5,LOW);
          delay(1000);
          digitalWrite(5,HIGH);
          delay(1000);
          digitalWrite(5,LOW);
          delay(1000);
          digitalWrite(5,HIGH);
          delay(1000);
          digitalWrite(5,LOW);
          delay(1000);
          digitalWrite(5,HIGH);
          delay(1000);
          digitalWrite(5,LOW);
          delay(1000);
          digitalWrite(33,HIGH);
  }
  if(digitalRead(31)==btndroite){
    if(auto==0){
       digitalWrite(2,HIGH);
       auto = 1;
       delay(200);
    }
    if(auto==1){
       digitalWrite(2,LOW);
       auto = 0;
       delay(200);
    }
  }
  if(digitalRead(29)==btngauche){
    digitalWrite(22,LOW);
    digitalWrite(53,LOW);
    delay(1000);
    digitalWrite(22,HIGH);
    digitalWrite(53,HIGH);
    delay(1000);
    digitalWrite(22,LOW);
    digitalWrite(53,LOW);
    delay(1000);
    digitalWrite(22,HIGH);
    digitalWrite(53,HIGH);
    delay(200);
  }
  
}

LES ERREURES:

mP_L-b-PP.ino:4:7: error: declaration does not declare anything [-fpermissive]
mP_L-b-PP.ino: In function 'void loop()':
mP_L-b-PP.ino:23:8: error: expected unqualified-id before '=' token
mP_L-b-PP.ino:120:8: error: decl-specifier invalid in condition
mP_L-b-PP.ino:120:8: error: expected primary-expression before 'auto'
mP_L-b-PP.ino:120:8: error: expected ')' before 'auto'
mP_L-b-PP.ino:122:13: error: expected unqualified-id before '=' token
mP_L-b-PP.ino:125:8: error: decl-specifier invalid in condition
mP_L-b-PP.ino:125:8: error: expected primary-expression before 'auto'
mP_L-b-PP.ino:125:8: error: expected ')' before 'auto'
mP_L-b-PP.ino:127:13: error: expected unqualified-id before '=' token
Erreur lors de la compilation.

1 réponse

NHenry Messages postés 15162 Date d'inscription vendredi 14 mars 2003 Statut Modérateur Dernière intervention 24 octobre 2024 340
30 janv. 2015 à 20:59
Au vu de la coloration syntaxique de
int auto;
Je pense que "auto" est un mot clé réservé.
0
Merci beaucoup ! je m'en suis rendu compte en meme temps que tu a posté ton message, et la tout va bien ! merci :)
0
Salut, je sais que c'est resolut, mais quand je l'ai mit sur l'arduino, il fait son travail de départ mais n'attend pas qu'il rentre dans un if, il recommence, comment faire ? code:
  int btnbas;
int btngauche;
int btndroite;
int azertyuiopqsdfg;

void setup() {
pinMode(53, OUTPUT); // blue 2
pinMode(22, OUTPUT); // blue 2
pinMode(33,OUTPUT); // green
pinMode(2,OUTPUT); // white
pinMode(35,INPUT); // btnbas
pinMode(5,OUTPUT); // red
pinMode(10,OUTPUT); // bip
pinMode(31,INPUT); // btndroite
pinMode(29,INPUT); // btngauche
}

void loop(){

btnbas = 1;
btngauche = 1;
btndroite = 1;
azertyuiopqsdfg = 0;

digitalWrite(22,HIGH);
digitalWrite(53,HIGH);
delay(200);
digitalWrite(33,LOW); // green
digitalWrite(2,LOW); // white
digitalWrite(5,LOW); // red
digitalWrite(10,LOW); // bip

delay(200);
digitalWrite(10,HIGH);
delay(200);
digitalWrite(10,LOW);

delay(2000);

digitalWrite(5,HIGH);
delay(1000);
digitalWrite(5,LOW);
delay(1000);
digitalWrite(5,HIGH);
delay(1000);
digitalWrite(5,LOW);
delay(1000);
digitalWrite(5,HIGH);
delay(1000);
digitalWrite(5,LOW);
delay(1000);
digitalWrite(5,HIGH);
delay(1000);
digitalWrite(5,LOW);
delay(1000);
digitalWrite(5,HIGH);
delay(1000);
digitalWrite(5,LOW);
delay(1000);
digitalWrite(5,HIGH);
delay(1000);
digitalWrite(5,LOW);
delay(1000);
digitalWrite(33,HIGH);

if(digitalRead(32)==btnbas){
digitalWrite(33,LOW); // green
digitalWrite(2,LOW); // white
digitalWrite(5,LOW); // red
digitalWrite(10,LOW); // bip

delay(200);
digitalWrite(10,HIGH);
delay(200);
digitalWrite(10,LOW);

delay(2000);

delay(200);
digitalWrite(10,HIGH);
delay(200);
digitalWrite(10,LOW);

digitalWrite(5,HIGH);
delay(1000);
digitalWrite(5,LOW);
delay(1000);
digitalWrite(5,HIGH);
delay(1000);
digitalWrite(5,LOW);
delay(1000);
digitalWrite(5,HIGH);
delay(1000);
digitalWrite(5,LOW);
delay(1000);
digitalWrite(5,HIGH);
delay(1000);
digitalWrite(5,LOW);
delay(1000);
digitalWrite(5,HIGH);
delay(1000);
digitalWrite(5,LOW);
delay(1000);
digitalWrite(5,HIGH);
delay(1000);
digitalWrite(5,LOW);
delay(1000);
digitalWrite(33,HIGH);
}
if(digitalRead(31)==btndroite){
if(azertyuiopqsdfg==0){
digitalWrite(2,HIGH);
azertyuiopqsdfg = 1;
delay(200);
}
if(azertyuiopqsdfg==1){
digitalWrite(2,LOW);
azertyuiopqsdfg = 0;
delay(200);
}
}
if(digitalRead(29)==btngauche){
digitalWrite(22,LOW);
digitalWrite(53,LOW);
delay(1000);
digitalWrite(22,HIGH);
digitalWrite(53,HIGH);
delay(1000);
digitalWrite(22,LOW);
digitalWrite(53,LOW);
delay(1000);
digitalWrite(22,HIGH);
digitalWrite(53,HIGH);
delay(200);
}
}
0
Antoinep52 > Antoinep52
30 janv. 2015 à 21:39
C'est bon, le code fonctionne :)
0
NHenry Messages postés 15162 Date d'inscription vendredi 14 mars 2003 Statut Modérateur Dernière intervention 24 octobre 2024 340
30 janv. 2015 à 23:19
Quelle était l'erreur ?
0