Hey, I have a Led cube and have made 3 functions for it, then I got Ken Shirriff's IRlibary and got each function (pattern or sequence w/e) to be turned on by a certain button on my remote the problem is, this only works once. So the function is run finished then all leds go off until I push another button. I want it to loop the function when i push the button until another button is pressed, but the problem is while the function is looping the code cant check for another button press as the function involves delays. How can i make it work, i cant use interrupts since i'm using delays and using the millis() method would get too complicated rather not go there.. any idea's?
The code in void loop so far..
void loop () {
//ir receiver bit
if (irrecv.decode(&results)) {
if (results.value == Button_1) {
Serial.write("Button 1 pressed\n");
pressed1 = 1;
}
else if (results.value == Button_2) {
Serial.write("Button 2 pressed\n");
pressed1 = 2;
}
else if (results.value == Button_3) {
Serial.write("Button 3 pressed\n");
pressed1 = 3;
}
else if (results.value == OFF) {
Serial.write("ON/OFF pressed\n");
pressed1 = 0;
allOff();
}
else {
Serial.println(results.value, HEX);
}
irrecv.resume(); // Receive the next value
}
// led cube bit
if (pressed1 == 1) {scrollthroughled ();}
else if (pressed1 == 2) {scrollupanddown ();}
else if (pressed1 == 3) {spinthroughlayers ();}
}
The whole code can be seen here IR_LED_Cube code - Pastebin.com
All help appreciated. ![]()