Unable to exit from "for" loop

First off… newbie which is why I’m asking for advice compared to helping other which I do hope to do so day.

Want to make something for halloween using code to travel from left to right and back again until a different key is pressed on the remote control. The problem is the once the “3” is pressed for the code Cylon is activated, pressing any other key does nothing. Using the monitor I do not see any other responses to other key presses. I am using the “car mp3 player” code from the web as a base setup.

case 0xFF10EF:

Serial.println(" 4 ");
Serial.println(“Cylon”);
for (q = 0; q < 20; q++)
{
Cylon();

if ((results.value) != 0xFF10EF)

break;

}

break;

void Cylon() {

FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);

for(int i = 0; i < NUM_LEDS; i++)
{

leds = CRGB( 30, 7, 1);//medium orange

  • FastLED.show();*
    _ leds = CRGB::Black;_
    * delay(20);*
    * }*
    * for(int i = NUM_LEDS-1;i >= 0; i–)
    _
    {_
    _ leds = CRGB( 30, 7, 1);//medium orange
    FastLED.show();
    leds = CRGB::Black;
    delay(20);
    }
    }*

    monitor response:
    IR Receiver Raw Data + Button Decode Test
    *4 *
    Cylon
    Any and all comments welcomed._

Half of your post is in italics.

Please edit your post, select the code, and put it between [code][/code] tags.

You can do that by hitting the # button above the posting area.

How to use this forum

You might also want to post the whole thing, I don't see where you are reading from Serial.

http://snippets-r-us.com/

Here is the complete code. what I don’t understand or are not correctly understanding is the break statement; from my understanding the code does the “for” and I thought with the statement of “if” values did not equal the results.value that this would force a break and drop out of the loop…but it does not when any other key is pressed.

#include "IRremote.h"
#include "FastLED.h"
#define NUM_LEDS 150
#define DATA_PIN 6
CRGB leds[NUM_LEDS];

int q = 0;

int receiver = 3; 

IRrecv irrecv(receiver);         

decode_results results;          


void setup() 

{

  Serial.begin(9600);

  Serial.println("IR Receiver Raw Data + Button Decode Test");

  irrecv.enableIRIn();

}

void loop() 

{

  if (irrecv.decode(&results)) 

  {

      translateIR();

    irrecv.resume(); 

  } 

}

void translateIR() 


{

  switch(results.value)

  {

  case 0xFFA25D: 

    Serial.println(" CH-            ");

    break;

  case 0xFF629D: 

    Serial.println(" CH             ");

    break;


  case 0xFFE21D: 

    Serial.println(" CH+            ");

    break;


  case 0xFF22DD: 

    Serial.println(" PREV           ");

    break;


  case 0xFF02FD:  

    Serial.println(" NEXT           ");

    break;


  case 0xFFC23D: 

    Serial.println(" PLAY/PAUSE     ");

    break;


  case 0xFFE01F: 

    Serial.println(" VOL-           ");

    break;


  case 0xFFA857: 

    Serial.println(" VOL+           ");

    break;


  case 0xFF906F: 

    Serial.println(" EQ             ");

    break;


  case 0xFF6897: 

    Serial.println(" 0              ");

    break;


  case 0xFF9867: 

    Serial.println(" 100+           ");

    break;


  case 0xFFB04F: 

    Serial.println(" 200+           ");

    break;


  case 0xFF30CF: 

    Serial.println(" 1              ");

    break;


  case 0xFF18E7: 

    Serial.println(" 2              ");

    break;


  case 0xFF7A85: 

    Serial.println(" 3              ");

    break;




  case 0xFF10EF: 

    Serial.println(" 4              ");
    Serial.println("Cylon");
    for (q = 0; q < 20; q++)

      Cylon();

    if ((results.value) != 0xFF10EF)

      break;
      
      

  case 0xFF38C7: 

    Serial.println(" 5              ");

    break;


  case 0xFF5AA5: 

    Serial.println(" 6              ");

    break;


  case 0xFF42BD: 

    Serial.println(" 7              ");

    break;


  case 0xFF4AB5: 

    Serial.println(" 8              ");

    break;


  case 0xFF52AD: 

    Serial.println(" 9              ");

    break;


  default:

    Serial.println(" other button   ");

  }

  delay(1);


} 


void Cylon() {

  FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);

  for(int i = 0; i < NUM_LEDS; i++)
  { 

    leds[i] = CRGB( 30, 7, 1);//medium orange
    FastLED.show();
    leds[i] = CRGB::Black;

    delay(20);
  }

  for(int i = NUM_LEDS-1;i >= 0; i--)
  {

    leds[i] = CRGB( 30, 7, 1);//medium orange
    FastLED.show();
    leds[i] = CRGB::Black;

    delay(20); 
  }

}

Maybe this will make it clearer what is happening:

Your if is checking for != 0xFF10EF ( is false) AFTER you case detect 0xFF10EF. Does Cyclon() changes the results.value ?

case 0xFF10EF: 
{          // start of case 
    Serial.println(" 4              ");
    Serial.println("Cylon");
   


 for (q = 0; q < 20; q++)
{
      Cylon();
}


    if ((results.value) != 0xFF10EF)
{
      break;
}
           ??????



} // end of case 

      
      

  case 0xFF38C7:

techIV:
Here is the complete code. what I don’t understand or are not correctly understanding is the break statement; from my understanding the code does the “for” and I thought with the statement of “if” values did not equal the results.value that this would force a break and drop out of the loop…but it does not when any other key is pressed.

#include "IRremote.h"

#include “FastLED.h”
#define NUM_LEDS 150
#define DATA_PIN 6
CRGB leds[NUM_LEDS];

int q = 0;

int receiver = 3;

IRrecv irrecv(receiver);

decode_results results;

void setup()

{

Serial.begin(9600);

Serial.println(“IR Receiver Raw Data + Button Decode Test”);

irrecv.enableIRIn();

}

void loop()

{

if (irrecv.decode(&results))

{

translateIR();

irrecv.resume();

}

}

void translateIR()

{

switch(results.value)

{

case 0xFFA25D:

Serial.println(" CH-            ");

break;

case 0xFF629D:

Serial.println(" CH             ");

break;

case 0xFFE21D:

Serial.println(" CH+            ");

break;

case 0xFF22DD:

Serial.println(" PREV           ");

break;

case 0xFF02FD:

Serial.println(" NEXT           ");

break;

case 0xFFC23D:

Serial.println(" PLAY/PAUSE     ");

break;

case 0xFFE01F:

Serial.println(" VOL-           ");

break;

case 0xFFA857:

Serial.println(" VOL+           ");

break;

case 0xFF906F:

Serial.println(" EQ             ");

break;

case 0xFF6897:

Serial.println(" 0              ");

break;

case 0xFF9867:

Serial.println(" 100+           ");

break;

case 0xFFB04F:

Serial.println(" 200+           ");

break;

case 0xFF30CF:

Serial.println(" 1              ");

break;

case 0xFF18E7:

Serial.println(" 2              ");

break;

case 0xFF7A85:

Serial.println(" 3              ");

break;

case 0xFF10EF:

Serial.println(" 4              ");
    Serial.println(“Cylon”);
    for (q = 0; q < 20; q++)

Cylon();

if ((results.value) != 0xFF10EF)

break;

case 0xFF38C7:

Serial.println(" 5              ");

break;

case 0xFF5AA5:

Serial.println(" 6              ");

break;

case 0xFF42BD:

Serial.println(" 7              ");

break;

case 0xFF4AB5:

Serial.println(" 8              ");

break;

case 0xFF52AD:

Serial.println(" 9              ");

break;

default:

Serial.println(" other button   ");

}

delay(1);

}

void Cylon() {

FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);

for(int i = 0; i < NUM_LEDS; i++)
  {

leds[i] = CRGB( 30, 7, 1);//medium orange
    FastLED.show();
    leds[i] = CRGB::Black;

delay(20);
  }

for(int i = NUM_LEDS-1;i >= 0; i–)
  {

leds[i] = CRGB( 30, 7, 1);//medium orange
    FastLED.show();
    leds[i] = CRGB::Black;

delay(20);
  }

}

void loop() 

{

  if (irrecv.decode(&results)) 

  {

    translateIR();

    irrecv.resume(); 

  } 

}

What's with the double-spacing? Are you writing an essay?

Your break statement is not in a for loop

   for (q = 0; q < 20; q++)
      Cylon();

    if ((results.value) != 0xFF10EF)
      break;

Since there are no braces following the ** for (q = 0; q < 20; q++)** The only instruction in your for loop is Cylon() It will complete this for loop before it even considers "if((reseults…blah blah…"l

If that was intended as part of the for loop it should have braces around it thus:

   for (q = 0; q < 20; q++)
     {  Cylon();

    if ((results.value) != 0xFF10EF)
      break;
   }
  case 0xFF10EF: 
    Serial.println(" 4              ");
    Serial.println("Cylon");
    for (q = 0; q < 20; q++)
      Cylon();
    if ((results.value) != 0xFF10EF)
      break;

results.value won’t change, so why test it there?

For the benefit of others, here is the code with blank lines removed:

#include "IRremote.h"
#include "FastLED.h"
#define NUM_LEDS 150
#define DATA_PIN 6
CRGB leds[NUM_LEDS];
int q = 0;
int receiver = 3; 
IRrecv irrecv(receiver);         
decode_results results;          
void setup() 
{
  Serial.begin(9600);
  Serial.println("IR Receiver Raw Data + Button Decode Test");
  irrecv.enableIRIn();
}
void loop() 
{
  if (irrecv.decode(&results)) 
  {
    translateIR();
    irrecv.resume(); 
  } 
}
void translateIR() 
{
  switch(results.value)
  {
  case 0xFFA25D: 
    Serial.println(" CH-            ");
    break;
  case 0xFF629D: 
    Serial.println(" CH             ");
    break;
  case 0xFFE21D: 
    Serial.println(" CH+            ");
    break;
  case 0xFF22DD: 
    Serial.println(" PREV           ");
    break;
  case 0xFF02FD:  
    Serial.println(" NEXT           ");
    break;
  case 0xFFC23D: 
    Serial.println(" PLAY/PAUSE     ");
    break;
  case 0xFFE01F: 
    Serial.println(" VOL-           ");
    break;
  case 0xFFA857: 
    Serial.println(" VOL+           ");
    break;
  case 0xFF906F: 
    Serial.println(" EQ             ");
    break;
  case 0xFF6897: 
    Serial.println(" 0              ");
    break;
  case 0xFF9867: 
    Serial.println(" 100+           ");
    break;
  case 0xFFB04F: 
    Serial.println(" 200+           ");
    break;
  case 0xFF30CF: 
    Serial.println(" 1              ");
    break;
  case 0xFF18E7: 
    Serial.println(" 2              ");
    break;
  case 0xFF7A85: 
    Serial.println(" 3              ");
    break;
  case 0xFF10EF: 
    Serial.println(" 4              ");
    Serial.println("Cylon");
    for (q = 0; q < 20; q++)
      Cylon();
    if ((results.value) != 0xFF10EF)
      break;
  case 0xFF38C7: 
    Serial.println(" 5              ");
    break;
  case 0xFF5AA5: 
    Serial.println(" 6              ");
    break;
  case 0xFF42BD: 
    Serial.println(" 7              ");
    break;
  case 0xFF4AB5: 
    Serial.println(" 8              ");
    break;
  case 0xFF52AD: 
    Serial.println(" 9              ");
    break;
  default:
    Serial.println(" other button   ");
  }
  delay(1);
} 
void Cylon() {
  FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
  for(int i = 0; i < NUM_LEDS; i++)
  { 
    leds[i] = CRGB( 30, 7, 1);//medium orange
    FastLED.show();
    leds[i] = CRGB::Black;
    delay(20);
  }
  for(int i = NUM_LEDS-1;i >= 0; i--)
  {
    leds[i] = CRGB( 30, 7, 1);//medium orange
    FastLED.show();
    leds[i] = CRGB::Black;
    delay(20); 
  }
}

added the irrecv function to read key press from remote for case 4 statement …thought that using the “do while” statement would work if followed by the != to break the while loop but this did not work. The report from the serial monitor indicates that it did not see the other key press … open to suggestions. Also wondering if this would be better situated to use an interrupt although I have read that the WS2811 and similar LED strips use code that turns off the interrupts.
Any and all comments welcomed.
On a side note; prior to using the IR remote, I had previously used a 6-position mechanical switch with no problems selecting different case statements. When I changed over to using the IR code, the LED code no longer looped continuously which is where I wanted to add the looping back in until another selection was made. The complete code was posted on an earlier posting.

  case 0xFF10EF:

    Serial.println(" 4  Cylon   ");
    if (irrecv.decode(&results))
      Serial.println(results.value, HEX);
    Serial.println("new key read; original key read = case selection");
    do
    {
      Cylon();
    }
    while (q < 200);
        if ((results.value) != 0xFF10EF)
        q++;
      break;

Serial Monitor response:

IR Receiver Raw Data + Button Decode Test
4 Cylon
FF10EF
new key read; original key read = case selection

    do
    {
      Cylon();
    }
    while (q < 200);

Once this loop starts, it will never end. You need to do something BETWEEN the curly braces, not after them, to enable breaking out of the loop.

Your break statement isn't inside the do-while loop at all. It is sitting just randomly a few statements after it.

It's also not conditional to that if statement. Only the q++ is. Those braces {} aren't just to make the code look pretty

Get a pencil and paper and work through each line of your code writing down the relevant values at each step - each step on a different line on the paper. Work round and round each loop that you come to until the code naturally leaves the loop.

That way you will see the code as the Arduino sees it and the problem should become apparent.

...R

complete original code previously posted;

case 0xFFC23D:
Serial.println(" StartInTheMiddle ");

for ( q = 0; q < 100; q++)
{
if (irrecv.decode(&results))
Serial.println(results.value, HEX);
StartInTheMiddle();
}
break;

monitor:
IR Receiver Raw Data + Button Decode Test
StartInTheMiddle
FFC23D
FFC23D
FFC23D
FFC23D
FFC23D
FFC23D
FFC23D
FFC23D
FFC23D
FFC23D
FFC23D
FFC23D
FFC23D
FFC23D

This was expected and the loop stops at 100.
However adding if ((results.value) != 0xFFC23D); inside the { and } stops the loop. The button was pressed 6 times and each time only one instance for each push of the button. Please Help !!

case 0xFFC23D:
Serial.println(" StartInTheMiddle ");

for ( q = 0; q < 1000; q++)
{
if (irrecv.decode(&results))
Serial.println(results.value, HEX);
StartInTheMiddle();
if ((results.value) != 0xFFC23D);
break;
}
break;

monitor:
IR Receiver Raw Data + Button Decode Test
StartInTheMiddle
FFC23D
StartInTheMiddle
FFC23D
StartInTheMiddle
FFC23D
StartInTheMiddle
FFC23D
StartInTheMiddle
FFC23D
StartInTheMiddle
FFC23D

for ( q = 0; q < 1000; q++)
    {
      if (irrecv.decode(&results))
        Serial.println(results.value, HEX);
      StartInTheMiddle();
      if ((results.value) != 0xFFC23D);
      break;
    }
    break;

\Why is there a break after the for loop?

However adding if ((results.value) != 0xFFC23D); inside the { and } stops the loop.

So, what is the problem?

previous case statement , uses break after print statment, thought this is required to exit from case statement
case 0xFF02FD:
Serial.println(" NEXT “);
break;
what I am missing here is I have a “if the value of the results does not equal the value of the case statement”, shouldn’t it break out of the loop? q starts at 0 and counts up to <1000 then drops out; each time q counts does it not read the irrecv value ? is it incorrect to use the “if” statement as a comparrison to break the loop?
case 0xFFC23D:
Serial.println(” StartInTheMiddle ");

for ( q = 0; q < 1000; q++)
{
if (irrecv.decode(&results))
Serial.println(results.value, HEX);
StartInTheMiddle();
if ((results.value) != 0xFFC23D);
// break;
}
break;

previous case statement , uses break after print statment, thought this is required to exit from case statement

Think again. What are you breaking out of? Hint: What are the curly braces that contain the break statement(s) for?

what I am missing here is I have a “if the value of the results does not equal the value of the case statement”, shouldn’t it break out of the loop?

Break out of what loop? What does the value of results.value have to do with a case value?

q starts at 0 and counts up to <1000 then drops out; each time q counts does it not read the irrecv value ?

What does the Serial.print() statement tell you? What does StartInTheMiddle() do? Why does that function have such a stupid name?

s it incorrect to use the “if” statement as a comparrison to break the loop?

No. That is fine. Commenting out the break statement that follows the if statement is not. The semicolon at the end of the if statement is not.

This is the complete code…all of it; the name of the function “startinthemiddle” does exactly what the name implies – the LED light strand starts in the middle and lights the LEDS on the left and right equally. I realize I am in a field of programming and I already stated that I am a newbie…looking for help & suggestions, have not programmed before and thought I could make something special for Halloween. From my understanding, the irrecv receives a data pulse from the remote and translates that into a hex value which is stored in “results”. I believe that this value will not change until the main loop is excuted. My thoughts are …if I performed a new read from the irrecv, that this value would be compared to the original hex value that was used to select the “switch-case” position. And that is where I have fallen off the log, any and all help appreciated.

#include "IRremote.h"
#include "FastLED.h"
#include <Adafruit_NeoPixel.h>
#define NUM_LEDS 150
#define DATA_PIN 6
CRGB leds[NUM_LEDS];
#define PIN 6
Adafruit_NeoPixel strip = Adafruit_NeoPixel(150, PIN, NEO_GRB + NEO_KHZ800);

int a = 0;  
int r =0;
int x = 47;
int d = 2;
int b = 75;  
int pos = 0, dir = 1;  
int j = 0;
int q = 0;
int receiver = 3; 

IRrecv irrecv(receiver);        
decode_results results;            

void setup()
{
  Serial.begin(9600);
  Serial.println("IR Receiver Raw Data + Button Decode Test");
  irrecv.enableIRIn(); // Start the receiver
}

void loop()  
{
  if (irrecv.decode(&results))
  {
    translateIR();
    irrecv.resume(); 
  } 
}

void translateIR() 
{
  switch(results.value)
  {
  case 0xFFA25D: 
    Serial.println(" CH-            ");
    break;
  case 0xFF629D: 
    Serial.println(" CH             ");
    break;
  case 0xFFE21D: 
    Serial.println(" CH+            ");
    break;
  case 0xFF22DD: 
    Serial.println(" PREV           ");
    break;
  case 0xFF02FD:  
    Serial.println(" NEXT           ");
    break;
  case 0xFFC23D: 
    Serial.println(" PLAY/PAUSE     ");
    break;
  case 0xFFE01F: 
    Serial.println(" VOL-           ");
    break;
  case 0xFFA857: 
    Serial.println(" VOL+           ");
    break;
  case 0xFF906F: 
    Serial.println(" EQ             ");
    break;
  case 0xFF6897: 
    Serial.println(" 0              ");
    break;
  case 0xFF9867: 
    Serial.println(" 100+           ");
    break;
  case 0xFFB04F: 
    Serial.println(" 200+           ");
    break;
  case 0xFF30CF: 
    Serial.println(" 1              ");
    Serial.println("StrandTest");
    StrandTest();
    break;
  case 0xFF18E7: 
    Serial.println(" 2              ");
    Serial.println("Larson Shades");
    larsonscannershades();
    break;
  case 0xFF7A85: 
    Serial.println(" 3              ");
    Serial.println("Start In The Middle");
    startinthemiddle();
    break;
  case 0xFF10EF: 
    Serial.println(" 4              ");
    Serial.println("Cylon");
    for (q = 0; q < 20; q++)
      Cylon();
    if ((results.value) != 0xFF10EF)
      break;
  case 0xFF38C7: 
    Serial.println(" 5              ");
    break;
  case 0xFF5AA5: 
    Serial.println(" 6              ");
    break;
  case 0xFF42BD: 
    Serial.println(" 7              ");
    break;
  case 0xFF4AB5: 
    Serial.println(" 8              ");
    break;
  case 0xFF52AD: 
    Serial.println(" 9              ");
    break;
  default:
    Serial.println(" other button   ");
  }
  delay(500); 
} 

void Cylon() {
  FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
  for(int i = 0; i < NUM_LEDS; i++)
  { 
    leds[i] = CRGB( 30, 7, 1);//medium orange
    FastLED.show();
    leds[i] = CRGB::Black;
    delay(20);
  }
  for(int i = NUM_LEDS-1;i >= 0; i--)
  {
    leds[i] = CRGB( 30, 7, 1);//medium orange
    FastLED.show();
    leds[i] = CRGB::Black;
    delay(20); 
  }
}


void larsonscannershades() {
  strip.begin();
  strip.show();
  strip.setPixelColor(pos - 6, 15, 2, 0); // dark orange
  strip.setPixelColor(pos - 5, 15, 2, 0); // dark orange
  strip.setPixelColor(pos - 4, 30, 5, 0); // medium orange
  strip.setPixelColor(pos - 3, 30, 5, 0); // medium orange
  strip.setPixelColor(pos - 2, 30, 5, 0); // medium orange
  strip.setPixelColor(pos - 1, 50, 14, 2); // orange
  strip.setPixelColor(pos    , 50, 14, 2); // orange
  strip.setPixelColor(pos + 1, 50, 14, 2); // orange
  strip.setPixelColor(pos + 2, 30, 5, 0); // medium orange
  strip.setPixelColor(pos + 3, 30, 5, 0); // medium orange
  strip.setPixelColor(pos + 4, 30, 5, 0); // medium orange
  strip.setPixelColor(pos + 5, 15, 2, 0); // dark orange
  strip.setPixelColor(pos + 6, 15, 2, 0); // dark orange
  strip.show();
  delay(50);
  for(j=-2; j<= 2; j++) strip.setPixelColor(pos+j, 0); 
  pos += dir;
  if(pos < 0) {
    pos = 1;
    dir = -dir;
  } 
  else if(pos >= strip.numPixels())
  {
    pos = strip.numPixels() - 2;
    dir = -dir;
  }
}


void startinthemiddle() {                 
  strip.begin();
  strip.show();
  for (int z = 74, y = 75; z<x, y>r; z++, y--) {  
    strip.setPixelColor(z, 50, 14, 2);  // orange
    strip.setPixelColor(y, 50, 14, 2);  // orange
    strip.show();
    delay(20);
    strip.setPixelColor(b, 30, 5, 0); 
    strip.setPixelColor(z, 0, 0, 0);
    strip.setPixelColor(y, 0, 0, 0);
    b++;
    strip.show();
  }
  strip.setPixelColor(r, 30, 5, 0);  // end of strip; color = medium orange
  strip.setPixelColor(x, 30, 5, 0);  // end of strip; color = medium orange
  strip.show();
  x--;
  r++;
  if (x<74)
  {
    x=75;
  }
  if (r>151)
  {
    r=0;
  }
  delay(10);
}

void StrandTest() {
  strip.begin();
  strip.show();
  colorWipe(strip.Color(255, 0, 0), 50); 
  colorWipe(strip.Color(0, 255, 0), 50); 
  colorWipe(strip.Color(0, 0, 255), 50); 
  theaterChase(strip.Color(127, 127, 127), 50); 
  theaterChase(strip.Color(127,   0,   0), 50); 
  theaterChase(strip.Color(  0,   0, 127), 50); 
  rainbow(20);
  rainbowCycle(20);
  theaterChaseRainbow(50);
}

void colorWipe(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<strip.numPixels(); i++) {
    strip.setPixelColor(i, c);
    strip.show();
    delay(wait);
  }
}

void rainbow(uint8_t wait) {
  uint16_t i, j;
  for(j=0; j<256; j++) {
    for(i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel((i+j) & 255));
    }
    strip.show();
    delay(wait);
  }
}

void rainbowCycle(uint8_t wait) {
  uint16_t i, j;
  for(j=0; j<256*5; j++) { 
    for(i=0; i< strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
    }
    strip.show();
    delay(wait);
  }
}

void theaterChase(uint32_t c, uint8_t wait) {
  for (int j=0; j<10; j++) {  
    for (int q=0; q < 3; q++) {
      for (int i=0; i < strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, c);   
      }
      strip.show();
      delay(wait);
      for (int i=0; i < strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, 0);      
      }
    }
  }
}

void theaterChaseRainbow(uint8_t wait) {
  for (int j=0; j < 256; j++) {    
    for (int q=0; q < 3; q++) {
      for (int i=0; i < strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, Wheel( (i+j) % 255));    
      }
      strip.show();
      delay(wait);
      for (int i=0; i < strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, 0);       
      }
    }
  }
}
uint32_t Wheel(byte WheelPos) {
  if(WheelPos < 85) {
    return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
  } 
  else if(WheelPos < 170) {
    WheelPos -= 85;
    return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  } 
  else {
    WheelPos -= 170;
    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
}
for(j=-2; j<= 2; j++) strip.setPixelColor(pos+j, 0);

That semicolon at the end is probably going to be a problem.

  case 0xFF10EF: 
    Serial.println(" 4              ");
    Serial.println("Cylon");
    for (q = 0; q < 20; q++)
      Cylon();
    if ((results.value) != 0xFF10EF)
      break;
  case 0xFF38C7: 
    Serial.println(" 5              ");
    break;

See reply #7. You haven’t responded to that.

First you check if results.value is 0xFF10EF. If so, you do something. Then you test the exact same thing again (except you are testing if it is not 0xFF10EF). Well it will be 0xFF10EF, so that test is useless. Then since it fails that test, it drops down to the next “case” which is 0xFF38C7.

results.value doesn’t magically change. You have to re-read the IR decoder (irrecv.decode(&results)) before it will change.