Replace delay with millis in Flash().
boolean flashing = false;
int flashingState = -1;
long nextFlashingState = 0;
void Flash() { // flashing function
if(!flashing ){
flashingState =-1;
return;
}
long ms = millis();
switch(flashingState ){
case -1:
flashingState =0;
nextflashingState = ms+75; //init "timer"
//fallthrough
case 0:
digitalWrite(rLED, LOW);
digitalWrite(gLED, LOW);
digitalWrite(bLED, LOW);
digitalWrite(rLED, HIGH);
if(nextflashingState < ms){
flashingState =1;
nextflashingState +=75;
}
break;
case 1:
digitalWrite(gLED, HIGH);
if(nextflashingState < ms){
flashingState = 2;
nextflashingState +=75;
}
break;
case 2:
digitalWrite(bLED, HIGH);
if(nextflashingState < ms){
flashingState = 3;
nextflashingState +=75;
}
break;
case 3:
digitalWrite(rLED, LOW);
if(nextflashingState < ms){
flashingState = 4;
nextflashingState +=75;
}
break;
case 4:
digitalWrite(gLED, LOW);
if(nextflashingState < ms){
flashingState = 5;
nextflashingState +=75;
}
break;
case 5:
digitalWrite(bLED, LOW);
if(nextflashingState < ms){
flashingState = 0;
nextflashingState +=75;
}
break;
}
}
Then in loop you call it every time.
void loop() {
if (irrecv.decode(&results))
{
if (results.value == BUTTON_ON)
{
digitalWrite(rLED, HIGH);
digitalWrite(gLED, HIGH);
digitalWrite(bLED, HIGH);
stR = HIGH;
stG = HIGH;
stB = HIGH;
}
if (results.value == BUTTON_OFF)
{
flashing =false;
digitalWrite(rLED, LOW);
digitalWrite(gLED, LOW);
digitalWrite(bLED, LOW);
stR = LOW;
stG = LOW;
stB = LOW;
}
if (results.value == BUTTON_R)
{
digitalWrite(rLED, !stR);
stR = !stR;
}
if (results.value == BUTTON_G)
{
digitalWrite(gLED, !stG);
stG = !stG;
}
if (results.value == BUTTON_B)
{
digitalWrite(bLED, !stB);
stB = !stB;
}
if (results.value == BUTTON_FLASH)
{
flashing =true;
}
irrecv.resume();
}
Flash();
}