Issues with nested decode calls using IRremote library.

Hello. This is my first post and I am pretty new to Arduino, but not programming. I feel like I have tried everything at this point, and I am not sure what I am doing wrong. I need to exit the animation that the light strip is performing whenever I press a button on the remote. Everything works for the 2 switch cases that do not have loops in them. It is just the one with the animation in it. When I print the value of the results.value inside of the switch case loop, it prints out a very large number that is not at all accurate. Please help me.

LEDtest.ino (3.25 KB)

@buds1998, please read How to use this forum - please read. - Installation & Troubleshooting - Arduino Forum, specifically point #7 about posting code; your code is small enough to include in the post instead of attaching.

OP's code so people using cell-phones can also contribute to the discussion :wink:

#include <IRremote.h>
#include <FastLED.h>

const int RECV_PIN = 8;
IRrecv irrecv(RECV_PIN);
IRsend irsend;
decode_results results;
unsigned long key_value = 0;

//FastLED Neopixel setup
#define NUMPIXELS 150
#define PIN 6
CRGB leds[NUMPIXELS];
int brightnessDelta = 4;
int brightness = 125;
int colorDelta = 5;

//colors
//accepts colors in green, red, blue
CRGB red = CRGB(0, 255, 0);
CRGB green = CRGB(255, 0, 0);
CRGB lightGreen = CRGB(204, 0, 102);
CRGB blue = CRGB(0, 0, 255);
CRGB lightBlue = CRGB(128, 0, 255);
CRGB skyBlue = CRGB(206, 135, 250);
CRGB lightSkyBlue = CRGB(216, 173, 230);
CRGB turquoise = CRGB(206, 0, 209);
CRGB lightTurquoise = CRGB(224, 64, 208);
CRGB darkTurquoise = CRGB(139, 0, 139);
CRGB white = CRGB(254, 254, 254);
CRGB darkOrange = CRGB(128, 255, 0);
CRGB orange = CRGB(153, 255, 51);
CRGB lightOrange = CRGB(178, 255, 102);
CRGB yellow = CRGB(255, 255, 0);
CRGB purple = CRGB(0, 153, 153);
CRGB lightPurple = CRGB(0, 204, 102);
CRGB pink = CRGB(105, 255, 180);
CRGB lightPink = CRGB(192, 255, 203);
CRGB darkPink = CRGB(20, 255, 147);

void setup() {
    // sanity check
    delay(2000);
  
    // setup IR reciever
    Serial.begin(9600);
    irrecv.enableIRIn();

    //blink arduino LED on input recieved
    irrecv.blink13(true);

    //FastLED NeoPixel
    FastLED.addLeds<WS2812B, PIN>(leds, NUMPIXELS);
    FastLED.clear();
    FastLED.setBrightness(brightness);
    FastLED.show();
}

void loop() {
    //if recieve ir input
    if (irrecv.decode(&results)) {

        Serial.println(results.bits);

        //holding button down functionality
        if (results.value == 0XFFFFFFFF) {
            results.value = key_value;
        }

        long int decCode = results.value;
        Serial.print(results.value);
        Serial.print("     ");
        Serial.println(decCode);

        switch(results.value) {
          
            //power [1][4]
            case 16712445:
                FastLED.clear();
                FastLED.show();
                break;
                
            //red R [2][1]
            case 16718565:
                FastLED.clear();
                fill_solid(leds, NUMPIXELS, red);
                FastLED.show();
                break;

            case 16724175:
                key_value = results.value;
                irrecv.resume();
                while (true) {
                    for (int i = 0; i < NUMPIXELS; i++) {
                        if (irrecv.decode(&results)) {
                            decCode = results.value;
                            Serial.println(results.value);
                            irsend.sendNEC(results.value, results.bits);
                            irrecv.enableIRIn();
                            FastLED.delay(100);
                            return;
                        }
                        FastLED.clear();
                        leds[i] = red;
                        FastLED.show();
                        FastLED.delay(500);
                    }
                }

            default:
                Serial.print(results.value);
                Serial.println(" not recognized.");
        }
        key_value = results.value;
        irrecv.resume();
    }
}

Sorry about that. Thanks for posting it.