many WTF error about variable

Hi, it's my first real project on arduino (just make blink some LEDs before). the goal is to control an arm to carries CDs from one driver to another. i've started the code but because he's little bit long, i've try to check it before ending it. After resolving the most classical error, the compiler tell me some error that i don't understand:

#include <Stepper.h>
#define STEPS 400
#define NOMBRE_DE_PAS 200
#define MILISEC_FOR_OPEN_DRIVER 1000

//Stepper MotorTranslation(STEPS, 50, 51, 52, 53);
Stepper MotorRotation(STEPS, 9, 10, 11, 12);

int ChoixJeux1=0;
int ChoixJeux2=1;
int ChoixJeux3=2;
int CapteurPressionCD=3;
int CapteurBrasHaut=7;
int CapteurPositionBras=8;

int data = 4;
int clock = 5;
int latch = 6;


int Lecteur = 0;

void descendre();
{
  do
  {
    digitalRead(CapteurPressionCD);
    if(CapteurPressionCD == LOW)
    {
      MotorTranslation.step(1);
    }
    delay(50);
  }while(CapteurPressionCD == LOW);
}

void setup()
{
  pinMode(ChoixJeux1, INPUT);
  pinMode(ChoixJeux2, INPUT);
  pinMode(ChoixJeux3, INPUT);
  pinMode(CapteurPressionCD, INPUT);
  pinMode(CapteurBrasHaut, INPUT);
  
  pinMode(data, OUTPUT);
  pinMode(clock, OUTPUT);
  pinMode(latch, OUTPUT);
  
  MotorRotation.setSpeed(10);
}

void loop()
{
  int JeuxChoisi=0;
  int JeuxCharge=0;
  
  Serial.begin(9600);
  
  JeuxChoisi = ReadChoixJeux();
  
  if(JeuxChoisi != 0)
  {
    do
    {
      digitalRead(CapteurBrasHaut);
      if(CapteurBrasHaut == LOW)
      {
        MotorTranslation.step(-1);
      }
      delay(50);
    }while(CapteurBrasHaut == LOW);
    
    do
    {
      digitalRead(CapteurPositionBras);
      if(CapteurPositionBras == LOW)
      {
        MotorRotation.step(-1);
      }
      delay(50);
    }while(CapteurPositionBras == LOW);
    
    switch(JeuxCharge)
    {
      case 0:
      PrendreUnJeux();
        break;
      
      case 1:
      RangerJeux(1);
      PrendreUnJeux(JeuxChoisi);
        break;
      
      case 2:
      RangerJeux(2);
      PrendreUnJeux(JeuxChoisi);
        break;
        
      case 3:
      RangerJeux(3);
      PrendreUnJeux(JeuxChoisi);
        break;
    }
  }
}

int ReadChoixJeux()
{
  int JeuxChoisi=0;
  
  digitalRead(ChoixJeux1);
  digitalRead(ChoixJeux2);
  digitalRead(ChoixJeux3);
  
  if(ChoixJeux1 == HIGH)
  {
    JeuxChoisi=1;
  }
  else if (ChoixJeux2 == HIGH)
  {
    JeuxChoisi=2;
  }
  else if (ChoixJeux3 == HIGH)
  {
    JeuxChoisi=3;
  }
  else
  {
    JeuxChoisi=0;
  }
  
  return JeuxChoisi;
}

void PrendreUnJeux(int JeuxChoisi)
{ 
  int puce=0;
  
  do
  {
    digitalRead(CapteurPositionBras);
    if(CapteurPositionBras == LOW)
    {
      MotorRotation.step(-1);
    }
    delay(50);
  }while(CapteurPositionBras == LOW);
  
  Lecteur = pow(2, JeuxChoisi-1);
  digitalWrite(latch, LOW);
  shiftOut(data, clock, MSBFIRST, Lecteur+puce);
  delay(MILISEC_FOR_OPEN_DRIVER);
  shiftOut(data, clock, MSBFIRST, puce);
  digitalWrite(latch, HIGH);
  
  descendre();
  
  digitalWrite(latch, LOW);
  puce = puce + 128;
  shiftOut(data, clock, MSBFIRST, puce);
  digitalWrite(latch, LOW);
  
  Monter();
  
  MotorRotation.step(NOMBRE_DE_PAS);
  
  descendre();
  
  digitalWrite(latch, LOW);
  puce = puce - 128;
  shiftOut(data, clock, MSBFIRST, puce);
  digitalWrite(latch, LOW);
  
  Monter();
  
  MotorRotation.step(-NOMBRE_DE_PAS);
}

void RangerJeux(int JeuxCharge)
{
  int puce=0;
  
  MotorRotation.step(NOMBRE_DE_PAS);
  
  descendre();
  
  digitalWrite(latch, LOW);
  puce = puce + 128;
  shiftOut(data, clock, MSBFIRST, puce);
  digitalWrite(latch, LOW);
  
  Monter();
  
  MotorRotation.step(-NOMBRE_DE_PAS);
  
  Lecteur = pow(2, JeuxCharge-1);
  digitalWrite(latch, LOW);
  puce = puce + lecteur;
  shiftOut(data, clock, MSBFIRST, puce);
  delay(MILISEC_FOR_OPEN_DRIVER);
  puce = puce - lecteur;
  shiftOut(data, clock, MSBFIRST, puce);
  digitalWrite(latch, HIGH);
  
  descendre();
  
  digitalWrite(latch, LOW);
  puce = puce - 128;
  shiftOut(data, clock, MSBFIRST, puce);
  digitalWrite(latch, LOW);
}

void Monter()
{
  do
  {
    digitalRead(CapteurBrasHaut);
    if(CapteurBrasHaut == LOW)
    {
      MotorTranslation.step(-1);
    }
    delay(50);
  }while(CapteurBrasHaut == LOW);
}

He say "Programme_TPE.cpp:31:1: error: expected unqualified-id before '{' token", but i don't see anything wrong at this point of my code.
Anyone?

but i don't see anything wrong at this point of my code.

I do:
void descendre();

:astonished:
ok that's embarrassing :cold_sweat:
thanks you for your very fast answer!
but now i have lot of error of undeclared variable:

Programme_TPE.cpp: In function 'void descendre()':
Programme_TPE.cpp:38:7: error: 'MotorTranslation' was not declared in this scope
Programme_TPE.cpp: In function 'void loop()':
Programme_TPE.cpp:75:9: error: 'MotorTranslation' was not declared in this scope
Programme_TPE.cpp:93:21: error: too few arguments to function 'void PrendreUnJeux(int)'
Programme_TPE.cpp:12:6: note: declared here
Programme_TPE.cpp: In function 'void RangerJeux(int)':
Programme_TPE.cpp:205:17: error: 'lecteur' was not declared in this scope
Programme_TPE.cpp: In function 'void Monter()':
Programme_TPE.cpp:227:7: error: 'MotorTranslation' was not declared in this scope

have you another magical answer for that please?
(the code is exactly the same excepted for the ';')

MotorTranslation is commented out.

Is there a guide on how to debug? Some of you gurus should write something.

Debugging only starts when the code compiles.

The best debugging advice ever from Kernigham and Plauger: "The Elements of Programming Style"

"Everyone knows that debugging is twice as hard as writing the program in the first place. So if you are as clever as you can be when you write it, how will you ever debug it?"

i probably need to go to sleep... i'm sorry to ask question who can be very simple for you but the two last error let me perplex.
why compiler say that "Programme_TPE.cpp:205:17: error: 'lecteur' was not declared in this scope"? and why he ask me for more arguments in "void prendreUnJeux"?

lecteur is not the same as Lecteur.

In case zero you call prendreUnJeux() with no arguments.

mistergreen:
Is there a guide on how to debug? Some of you gurus should write something.

It's not that simple. Debugging is a multi-aspect skill using knowledge, intuition and persistence. Often lots more persistence than people will believe.

There are many techniques from printing out values to strip-down troubleshooting to walk away and come back fresh but when to do what takes practice to have even a good idea what to try.

Start with persistence and learn from there when to stop beating your head on a wall and look around it, but without persistence most debugging doesn't get far.

Another basic is to learn that often what looks like the problem isn't the problem and it's easy to write bugs into code when trying to rush a job.

why compiler say that "Programme_TPE.cpp:205:17: error: 'lecteur' was not declared in this scope"?

Because it wasn't
If you think it was then it is you that is wrong not the compiler.
The compiler is very stupid, it is easly confused, but it is always right. It is your job to find out why YOU have confused the compiler.

Ok this prove that the error is always from programmer witch don't have to report it on the IDE.
Thank you all, you are very powerful for being able to find that error in a very fast time.
what a long way for me...

Actually the best debugging tool is knowing the language well enough to execute it yourself, step by step.

When you get an error like this

"Programme_TPE.cpp:205:17: error: 'lecteur' was not declared in this scope"

, the simplest remedy is to do a case-sensitive search in your code for "lecteur".
There should be at least two occurrences, one of which should be a form of declaration.

A lesson I learned early on when getting started with arduino is that the compiler is great at detecting errors but pretty much sucks at explaining what exactly caused the errors. Once you come to accept that and use the error messages as just vague hints it's not all that bad.

Lefty

I have heard that this is one of the reasons Apple switched from gcc to clang. The error messages are actually helpful.

A lesson I learned early on when getting started with arduino is that the compiler is great at detecting errors but pretty much sucks at explaining what exactly caused the errors.

I'm not sure I agree.

If the compiler reported:

"Programme_TPE.cpp:205:17: Zirconium was found on Mars, at WalMart"

would be a useless error message. All you would know was where the error was found.

But, it reports:

"Programme_TPE.cpp:205:17: error: 'lecteur' was not declared in this scope"

Not only is the file containing the error defined, the line and column number are defined, and the exact issue.

I don't know of a way to make this clearer. Do you have any suggestions on the wording for this error message that would make it easier to determine the fix needed?

After a dive in a rocky cove in Rhode Island, the more experienced divers were exclaiming about the large numbers of lobster they'd seen. I saw none, but on saying this, was told "You have to accustom your eyes". On a subsequent occasion, I finally noticed that although you don't see the lobster itself, their antennae are often plainly visible and that that area is indeed overrun with lobster.

This is the same thing; that error message made it blatantly obvious what the issue was - after you've seen it five or six times. It's like the = vs == issue, you can't see it until you "accustom your eyes" :wink:

We grow up used to talking with people, filling in gaps and making leaps and often not noticing when there are two different conversations being taken as one. As long as you're close, hey? Each sees what they think, biased towards what they want.

And then you deal with the machine that uses words and logic and it doesn't fill in or guess at your meaning. But your mind sees lecteur and Lecteur as the same, so the machine is wrong as far as you're concerned. Or you don't see the ; where there should be none because every line should end with ; or some other made up rule you filled in when sort of learning and won't unlearn without practice.

And the best part is you can code for a lifetime and still not get all of your own bugs out. I certainly never did because I still get compile errors, still double-check libraries at times. The only thing getting upset, frustrated and emotional about does is to prolong the process so fix what you can, blow it off for a while and get back to it when you've cooled down... that's persistence.

mistergreen:
Is there a guide on how to debug? Some of you gurus should write something.

I assume you mean "debug" compiler errors.

When I move to a new compiler I like to add single errors in a controlled manner to see what the compiler says.
Usual favourites are: dropping off a semi-colon, missing bracket, one extra/one less brace, variable mispelling (including case),
wrong number of arguments, syntax error using /= for !=

I always like to declare my procedures at the start it makes it easier to cut and paste the signature each time it's used.

The problem is a lot worse when the compiler does not catch the error and it becomes a program logic error. The syntax error above is a typical example of this since it can be computed in c-style languages. (it is not equals in ada). Make a mental note of the typical compiler errors and a list of those that it doesn't catch for when things go wrong and you need to debug.