So I have this code to control my three leds using IR remote. With this code the while loop runs only once, does anybody knows how to make it run until I press any other button on the remote?
#include <IRremote.h>
#include <Adafruit_NeoPixel.h>
int LEDP = 6;
int pocet = 3;
Adafruit_NeoPixel pixely(pocet, LEDP, NEO_GRB + NEO_KHZ800);
const int RECV_PIN = 3;
IRrecv irrecv(RECV_PIN);
decode_results results;
unsigned long key_value = 0;
void setup(){
Serial.begin(9600);
irrecv.enableIRIn();
irrecv.blink13(true);
pixely.begin();
}
void loop() {
if (irrecv.decode(&results)) {
if (results.value == 0xFFFFFFFF) {
results.value = key_value;
} // if
switch (results.value) {
case 0xFF6897:
pixely.setPixelColor(0, pixely.Color(0,0,0));
pixely.setPixelColor(1, pixely.Color(0,0,0));
pixely.setPixelColor(2, pixely.Color(0,0,0));
pixely.show();
break;
case 0xFF30CF:
pixely.setPixelColor(0, pixely.Color(0,255,0));
pixely.setPixelColor(1, pixely.Color(0,255,0));
pixely.setPixelColor(2, pixely.Color(0,255,0));
pixely.show();
break;
case 0xFF18E7:
pixely.setPixelColor(0, pixely.Color(150,150,150));
pixely.setPixelColor(1, pixely.Color(150,150,150));
pixely.setPixelColor(2, pixely.Color(150,150,150));
pixely.show();
break;
case 0xFF7A85:
pixely.setPixelColor(0, pixely.Color(150,150,150));
pixely.setPixelColor(1, pixely.Color(0,0,0));
pixely.setPixelColor(2, pixely.Color(0,0,0));
pixely.show();
break;
case 0xFF10EF:
pixely.setPixelColor(0, pixely.Color(0,0,0));
pixely.setPixelColor(1, pixely.Color(0,0,0));
pixely.setPixelColor(2, pixely.Color(150,150,150));
pixely.show();
break;
case 0xFF38C7:
pixely.setPixelColor(0, pixely.Color(0,0,0));
pixely.setPixelColor(1, pixely.Color(150,150,150));
pixely.setPixelColor(2, pixely.Color(0,0,0));
pixely.show();
break;
case 0xFF5AA5:
irrecv.resume();
while (0xFF5AA5 == results.value) {
pixely.setPixelColor(0, pixely.Color(150,150,150));
pixely.setPixelColor(1, pixely.Color(0,0,0));
pixely.setPixelColor(2, pixely.Color(0,0,0));
pixely.show();
delay(1000);
pixely.setPixelColor(0, pixely.Color(0,0,0));
pixely.setPixelColor(1, pixely.Color(0,0,0));
pixely.setPixelColor(2, pixely.Color(150,150,150));
pixely.show();
delay(1000);
pixely.setPixelColor(0, pixely.Color(0,0,0));
pixely.setPixelColor(1, pixely.Color(150,150,150));
pixely.setPixelColor(2, pixely.Color(0,0,0));
pixely.show();
delay(1000);
pixely.setPixelColor(0, pixely.Color(150,150,150));
pixely.setPixelColor(1, pixely.Color(150,150,150));
pixely.setPixelColor(2, pixely.Color(150,150,150));
pixely.show();
delay(1000);
if (irrecv.decode(&results)) {
break;
} // if
} // while
break;
} // switch
key_value = results.value;
irrecv.resume();
} // if
} // loop()