Expected identifier before ']' token and expected ',' before ';' token

switch(cmd)[
        case '1': [ //------------- avancer
        analogWrite(RD_AV,carSpeed);
        analogWrite(RG_AV,carSpeed);
      ]break;

      case '2': [ //----------- reculer
         analogWrite(RD_AR,carSpeed),
         analogWrite(RG_AR,carSpeed),
         ]break;

         case '3': [ //----------- tourner a droite
           analogWrite(RD_AR,carSpeed),
           analogWrite(RG_AV,carSpeed),
         ]break;

         case '4': [ //------------ tourner a gauche
          analogWrite(RD_AV,carSpeed),
          analogWrite(RG_AR,carSpeed),
          ]

(Code tags added by Moderator. Next time, please use the </> button on the menu.)

Wrong shaped brackets.
See
https://www.arduino.cc/reference/en/language/structure/control-structure/switchcase/

it does not work

switch(cmd){
        case '1':  //------------- avancer
        analogWrite(RD_AV,carSpeed);
        analogWrite(RG_AV,carSpeed);
      break;

      case '2':  //----------- reculer
         analogWrite(RD_AR,carSpeed);
         analogWrite(RG_AR,carSpeed);
         break;

         case '3':  //----------- tourner a droite
           analogWrite(RD_AR,carSpeed);
           analogWrite(RG_AV,carSpeed);
         break;

         case '4':  //------------ tourner a gauche
          analogWrite(RD_AV,carSpeed);
          analogWrite(RG_AR,carSpeed);
          break;
}

Try that. Note ; and { } usage

thank you
but in this line

      if( cmd == 'a' && vitesse <= 90 )[ vitesse=vitesse+10; ]
 else if( cmd == 'd' && vitesse > 0   )[ vitesse=vitesse-10; ]
it told me expected ',' before ']' token 

do you know how to fix that please ?

Incorrect symbols again:

if( cmd == 'a' && vitesse <= 90 )
{ 
vitesse=vitesse+10; 
}
 
else if( cmd == 'd' && vitesse > 0   )
{ 
vitesse=vitesse-10; 
}

Note { } vs [ ]

im veryyy sorry to disturb you again but why this :
in this line
arreterRobot() ;
it told me 'expected constructor, destructor or type conversion before ‘;’ token

You have an extra ‘}’ before that line. You can’t put that line outside of a function.

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