What causes this error? (For Loop)

Maybe I am tired, but I don't see what I have done wrong (obviously something)....

void transmitUniverseDMX_1() { 

  for (byte i = 1; i < 11; i++) {                                                                                
    switch (dmxuni_1TYP[i]) {                                                                                 
      case 1:                                                                                                  
        break;
      case 2:                                                                                                    
        break;
      case 3:                                                                                                 
        break;
      case 4:                                                                                                    
        break;
      case 5:                                                                                                    
        break;
      case 6:                                                                                                   
        break;
      case 7:                                                                                                     
        break;
      case 8:                                                                                                 
        break;
      case 9:                                                                                                    
        break;
      case 10:                                                                                                   
        break;
    }
  }
}

I get the error:

C:\Users\steve\Documents\Arduino\Teensy_4.1_main_DMXcontroller\Teesny_4.1_main_DMXcontroller\Teensy_4.1_main_DMXcontroller_v34\Teensy_4.1_main_DMXcontroller_v34.ino: In function 'void transmitUniverseDMX_1()':
C:\Users\steve\Documents\Arduino\Teensy_4.1_main_DMXcontroller\Teesny_4.1_main_DMXcontroller\Teensy_4.1_main_DMXcontroller_v34\Teensy_4.1_main_DMXcontroller_v34.ino:2491:26: warning: iteration 9u invokes undefined behavior [-Waggressive-loop-optimizations]
     switch (dmxuni_1TYP[i]) {                                                                                     // Check what type of output the channel is
                          ^
C:\Users\steve\Documents\Arduino\Teensy_4.1_main_DMXcontroller\Teesny_4.1_main_DMXcontroller\Teensy_4.1_main_DMXcontroller_v34\Teensy_4.1_main_DMXcontroller_v34.ino:2490:21: note: containing loop
   for (int i = 1; i < 11; i++) {                                                                                 // Check all 10 channels

We don’t see it either. You should post your complete sketch.

My bet is that dmxuni_1TYP declaration is not consistent with how you use it here

As soon as I posted it..... I found it. ALWAYS happens.

The for loop is searching an array from 0-10, not 1 to 11.

Dumb moment number 324

is to go past, or make it look like you are planning to, the end of the array dmxuni_1TYP.

a7

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