Low voltage motor driver and switch statement

Hello,
I have tried to figure this one out with no luck. I am building my first Tamiya tank robot. Using a pololu low voltage motor driver and an arduino Mega. When I try to compile the program, at the switch statement the program stops. I get the the error, “Jump to case lable”. I believe I am using the switch statement correctly but something is wrong. Hopefully I am using the driver commands correctly inside the switch statement. Can you please help?
Thank you.

int reset = 9; // resets and enables the motor driver.  Pos for enabled

unsigned int data = 0;
unsigned int xval = 0;
unsigned int yval = 0;

unsigned int Lhibyte = 0;  //byte # 11
unsigned int Llowbyte = 0;  // byte # 12

unsigned int Rhibyte = 0;  //byte # 13
unsigned int Rlowbyte = 0; // byte #14

unsigned int xblock = 0;
unsigned int yblock = 0;

unsigned int joystickPos = 0;

void setup()
{
  Serial.begin(9600);
  Serial1.begin(14400);
   
  pinMode(reset, OUTPUT);
  digitalWrite(reset,LOW);
  delay(5);  
  digitalWrite(reset,HIGH);
  delay(5);
  
}
  
  void loop()
  {
    if(Serial1.available()>0)  // checks for data
     {
       data = Serial1.read();  // reads data from Serial
   
       if(data==0x7E)  //start delimiter, byte read and gets thrown away
         {
           for(int i = 0; i <12; i++)   //counter
             {
               Serial1.read();  //reads and removes bytes 1 through 10 from the buffer
               delay(1);      
             }
         
           Lhibyte = Serial1.read();
           delay(1);
       
           Llowbyte = Serial1.read();
           delay(1);
       
           Rhibyte = Serial1.read();
           delay(1);
           Rlowbyte = Serial1.read();
           delay(1);
   
    
    switch (joystickPos)
    {
      case 133:  // joystick centered no movement. all stop
      byte leftM[4] = {0x80,0x00,0x05,0x00};  
      byte rigtM[4] = {0x80,0x00,0x07,0x00};      
      Serial1.write(leftM,4);  
      Serial1.write(rigtM,4);      
      break;
    
      case 134:   // forward both motors half speed
      byte leftM[4] = {0x80,0x00,0x05,0x3F};  
      byte rigtM[4] = {0x80,0x00,0x07,0x3F};      
      Serial1.write(leftM,4);  
      Serial1.write(rigtM,4);      
      break;
      
      case 135:    //forward both motors full speed
      byte leftM[4] = {0x80,0x00,0x05,0x7F};  
      byte rigtM[4] = {0x80,0x00,0x07,0x7F};      
      Serial1.write(leftM,4);  
      Serial1.write(rigtM,4);   
      break;
      
      case 132:  // reverse both motors half speed
      byte leftM[4] = {0x80,0x00,0x04,0x3F};  
      byte rigtM[4] = {0x80,0x00,0x06,0x3F};      
      Serial1.write(leftM,4);  
      Serial1.write(rigtM,4);   
      break;
      
      case 131:  // reverse both motors full speed
      byte leftM[4] = {0x80,0x00,0x04,0x7F};  
      byte rigtM[4] = {0x80,0x00,0x06,0x7F};      
      Serial1.write(leftM,4);  
      Serial1.write(rigtM,4);  
      break;
      
      case 145:  // STEER RIGHT FORWARD
      case 155:
      case 144:
      case 154:
      byte leftM[4] = {0x80,0x00,0x05,0x7F};  
      byte rigtM[4] = {0x80,0x00,0x07,0x3F};      
      Serial1.write(leftM,4);  
      Serial1.write(rigtM,4);  
      break;
          
      
      case 115:  // LEFT TURN FORWARD
      case 125:
      case 114:
      case 124:
      byte leftM[4] = {0x80,0x00,0x05,0x3F};  
      byte rigtM[4] = {0x80,0x00,0x07,0x7F};      
      Serial1.write(leftM,4);  
      Serial1.write(rigtM,4);  
      break;
      
      
      case 112:  // LEFT TURN BACKWARD
      case 122:
      case 111:
      case 121:
      byte leftM[4] = {0x80,0x00,0x04,0x3F};  
      byte rigtM[4] = {0x80,0x00,0x06,0x7F};      
      Serial1.write(leftM,4);  
      Serial1.write(rigtM,4);  
      break;
      
      case 142:  // RIGHT TURN BACKWARD
      case 152:
      case 141:
      case 151:
      byte leftM[4] = {0x80,0x00,0x04,0x7F};  
      byte rigtM[4] = {0x80,0x00,0x06,0x3F};      
      Serial1.write(leftM,4);  
      Serial1.write(rigtM,4);  
      break;
      
      case 123:  //spin left on itself half speed
      byte leftM[4] = {0x80,0x00,0x04,0x3F};  
      byte rigtM[4] = {0x80,0x00,0x07,0x3F};      
      Serial1.write(leftM,4);  
      Serial1.write(rigtM,4);  
      break;
      
      case 113:  //spin left on itself full speed
      byte leftM[4] = {0x80,0x00,0x04,0x7F};  
      byte rigtM[4] = {0x80,0x00,0x07,0x7F};      
      Serial1.write(leftM,4);  
      Serial1.write(rigtM,4);  
      break;
      
      case 143:  //spin right on itself half speed
      byte leftM[4] = {0x80,0x00,0x05,0x3F};  
      byte rigtM[4] = {0x80,0x00,0x06,0x3F};      
      Serial1.write(leftM,4);  
      Serial1.write(rigtM,4);  
      break;
      
      case 153:  //spin right on itself full speed
      byte leftM[4] = {0x80,0x00,0x05,0x7F};  
      byte rigtM[4] = {0x80,0x00,0x06,0x7F};      
      Serial1.write(leftM,4);  
      Serial1.write(rigtM,4);  
      break;
      
    }
    
  }
  }

I forgot one part of the code. Here is the corrected code.
Thank you.

// left motor #2, fwd 0x05, bkwd 0x04  :::  right motor#3 fwd 0x07,bkwd 0x06


int reset = 9; // resets and enables the motor driver.  Pos for enabled

unsigned int data = 0;
unsigned int xval = 0;
unsigned int yval = 0;

unsigned int Lhibyte = 0;  //byte # 11
unsigned int Llowbyte = 0;  // byte # 12

unsigned int Rhibyte = 0;  //byte # 13
unsigned int Rlowbyte = 0; // byte #14

unsigned int xblock = 0;
unsigned int yblock = 0;

unsigned int joystickPos = 0;

void setup()
{
  Serial.begin(9600);
  Serial1.begin(14400);
   
  pinMode(reset, OUTPUT);
  digitalWrite(reset,LOW);
  delay(5);  
  digitalWrite(reset,HIGH);
  delay(5);
  
}
  
  void loop()
  {
    if(Serial1.available()>0)  // checks for data
     {
       data = Serial1.read();  // reads data from Serial
   
       if(data==0x7E)  //start delimiter, byte read and gets thrown away
         {
           for(int i = 0; i <12; i++)   //counter
             {
               Serial1.read();  //reads and removes bytes 1 through 10 from the buffer
               delay(1);      
             }
         
           Lhibyte = Serial1.read();
           delay(1);
       
           Llowbyte = Serial1.read();
           delay(1);
       
           Rhibyte = Serial1.read();
           delay(1);
           Rlowbyte = Serial1.read();
           delay(1);
     
    
    xval = word(Lhibyte,Llowbyte);  // left motor
    yval = word(Rhibyte,Rlowbyte);  // Right motor
    
    xblock = map(xval, 0, 1023, 1, 6);  
    yblock = map(yval, 0, 1023, 1, 6);
    
    joystickPos = xblock*10 + yblock + 100;
    
   
    
    switch (joystickPos)
    {
      case 133:  // joystick centered no movement. all stop
      byte leftM[4] = {0x80,0x00,0x05,0x00};  
      byte rigtM[4] = {0x80,0x00,0x07,0x00};      
      Serial1.write(leftM,4);  
      Serial1.write(rigtM,4);      
      break;
    
      case 134:   // forward both motors half speed
      byte leftM[4] = {0x80,0x00,0x05,0x3F};  
      byte rigtM[4] = {0x80,0x00,0x07,0x3F};      
      Serial1.write(leftM,4);  
      Serial1.write(rigtM,4);      
      break;
      
      case 135:    //forward both motors full speed
      byte leftM[4] = {0x80,0x00,0x05,0x7F};  
      byte rigtM[4] = {0x80,0x00,0x07,0x7F};      
      Serial1.write(leftM,4);  
      Serial1.write(rigtM,4);   
      break;
      
      case 132:  // reverse both motors half speed
      byte leftM[4] = {0x80,0x00,0x04,0x3F};  
      byte rigtM[4] = {0x80,0x00,0x06,0x3F};      
      Serial1.write(leftM,4);  
      Serial1.write(rigtM,4);   
      break;
      
      case 131:  // reverse both motors full speed
      byte leftM[4] = {0x80,0x00,0x04,0x7F};  
      byte rigtM[4] = {0x80,0x00,0x06,0x7F};      
      Serial1.write(leftM,4);  
      Serial1.write(rigtM,4);  
      break;
      
      case 145:  // STEER RIGHT FORWARD
      case 155:
      case 144:
      case 154:
      byte leftM[4] = {0x80,0x00,0x05,0x7F};  
      byte rigtM[4] = {0x80,0x00,0x07,0x3F};      
      Serial1.write(leftM,4);  
      Serial1.write(rigtM,4);  
      break;
          
      
      case 115:  // LEFT TURN FORWARD
      case 125:
      case 114:
      case 124:
      byte leftM[4] = {0x80,0x00,0x05,0x3F};  
      byte rigtM[4] = {0x80,0x00,0x07,0x7F};      
      Serial1.write(leftM,4);  
      Serial1.write(rigtM,4);  
      break;
      
      
      case 112:  // LEFT TURN BACKWARD
      case 122:
      case 111:
      case 121:
      byte leftM[4] = {0x80,0x00,0x04,0x3F};  
      byte rigtM[4] = {0x80,0x00,0x06,0x7F};      
      Serial1.write(leftM,4);  
      Serial1.write(rigtM,4);  
      break;
      
      case 142:  // RIGHT TURN BACKWARD
      case 152:
      case 141:
      case 151:
      byte leftM[4] = {0x80,0x00,0x04,0x7F};  
      byte rigtM[4] = {0x80,0x00,0x06,0x3F};      
      Serial1.write(leftM,4);  
      Serial1.write(rigtM,4);  
      break;
      
      case 123:  //spin left on itself half speed
      byte leftM[4] = {0x80,0x00,0x04,0x3F};  
      byte rigtM[4] = {0x80,0x00,0x07,0x3F};      
      Serial1.write(leftM,4);  
      Serial1.write(rigtM,4);  
      break;
      
      case 113:  //spin left on itself full speed
      byte leftM[4] = {0x80,0x00,0x04,0x7F};  
      byte rigtM[4] = {0x80,0x00,0x07,0x7F};      
      Serial1.write(leftM,4);  
      Serial1.write(rigtM,4);  
      break;
      
      case 143:  //spin right on itself half speed
      byte leftM[4] = {0x80,0x00,0x05,0x3F};  
      byte rigtM[4] = {0x80,0x00,0x06,0x3F};      
      Serial1.write(leftM,4);  
      Serial1.write(rigtM,4);  
      break;
      
      case 153:  //spin right on itself full speed
      byte leftM[4] = {0x80,0x00,0x05,0x7F};  
      byte rigtM[4] = {0x80,0x00,0x06,0x7F};      
      Serial1.write(leftM,4);  
      Serial1.write(rigtM,4);  
      break;
      
    }
    
  }
  }

Your problem is you have many duplicate declarations of leftM and rightM. You can fix this by putting them within their own scope to the declarations do not overlap.

In other words, use curly braces between the case statement and the break statement.

For example:

      case 133:  // joystick centered no movement. all stop
      {  //  <---  HERE
        byte leftM[4] = {0x80,0x00,0x05,0x00};  
        byte rigtM[4] = {0x80,0x00,0x07,0x00};      
        Serial1.write(leftM,4);  
        Serial1.write(rigtM,4);
      }  // <---- AND HERE
      break;

Do that for every case statement and you won’t receive that error message because any variable declared within the curly braces is within its own scope.

Great!! I’ll do this. I am almost done with my tank robot. It has taken 1.5 months and I am getting close.
thank you,
Scott