Using a infared remote to end a looping program.

ill start this off by saying i'm new to the world of arduinos and this is my first project. what im trying to do is to have a remote to control 4 rgb leds to toggle with a infrared remote what colour they emit (i have this part). then i also want to have a looping program will cycle through each colour by pressing another remote button, until another button is pressed that will stop it. i have been trying to figure this out for a few days and all i can find is things that dont do what i want them to do( like looping for x amount of cycles then stopping)

#include <IRremote.h>
#include <IRremoteInt.h>

int redpin =2;
int bluepin =3;
int greenpin =4;
int RECV_PIN = 11;
int i=0;
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver

pinMode(RECV_PIN,INPUT);
pinMode(redpin, OUTPUT);
pinMode(bluepin, OUTPUT);
pinMode(greenpin, OUTPUT);
}

void loop()
{
if (irrecv.decode(&results))
{
Serial.println(results.value, HEX); // Use HEX or DEC
irrecv.resume(); // Receive the next value
}

switch(results.value){
case 0xFF30CF: // when button 1 is pressed only red will turn on
digitalWrite(redpin, HIGH);
digitalWrite(greenpin, LOW);
digitalWrite(bluepin, LOW);
break;

case 0xFF18E7: // when button 2 is pressed only blue will turn on
digitalWrite(bluepin, HIGH);
digitalWrite(greenpin, LOW);
digitalWrite(redpin, LOW);
break;

case 0xFF7A85: // when button 3 is pressed only green will turn on
digitalWrite(greenpin, HIGH);
digitalWrite(redpin, LOW);
digitalWrite(bluepin, LOW);
break;

case 0xFF10EF: // when button 4 is pressed only leds red and blue will turn on
digitalWrite(redpin, HIGH);
digitalWrite(bluepin, HIGH);
digitalWrite(greenpin, LOW);
break;

case 0xFF38C7: // when button 5 is press only leds blue and gree will turn on
digitalWrite(greenpin, HIGH);
digitalWrite(bluepin, HIGH);
digitalWrite(redpin, LOW);
break;

case 0xFF5AA5: // when button 6 is press only leds green and red will turn on
digitalWrite(greenpin, HIGH);
digitalWrite(redpin, HIGH);
digitalWrite(bluepin, LOW);
break;

case 0xFF42BD: // when button 7 is pressed all led colours will be on
digitalWrite(greenpin, HIGH);
digitalWrite(redpin, HIGH);
digitalWrite(bluepin, HIGH);
break;

case 0xFF4AB5: //starts "party mode" when button #8 is pressed and will run through each colour combo untill i=3
for (i=0;i<3;i++){
digitalWrite(redpin, HIGH);
digitalWrite(greenpin, LOW);
digitalWrite(bluepin, LOW);
delay (250);
digitalWrite(redpin, LOW);
digitalWrite(greenpin, HIGH);
digitalWrite(bluepin, LOW);
delay (250);
digitalWrite(redpin, LOW);
digitalWrite(greenpin, LOW);
digitalWrite(bluepin, HIGH);
delay (250);
digitalWrite(redpin, HIGH);
digitalWrite(greenpin, HIGH);
digitalWrite(bluepin, LOW);
delay (250);
digitalWrite(redpin, HIGH);
digitalWrite(greenpin, LOW);
digitalWrite(bluepin, LOW);
delay (250);
digitalWrite(redpin, LOW);
digitalWrite(greenpin, HIGH);
digitalWrite(bluepin, HIGH);
delay (250);
digitalWrite(redpin, HIGH);
digitalWrite(greenpin, HIGH);
digitalWrite(bluepin, HIGH);
delay (250);

}
case 0xFF6897: // ALL OFF (Stop button)
digitalWrite(greenpin, LOW);
digitalWrite(redpin, LOW);
digitalWrite(bluepin, LOW);
break;

}

}

this is currently my code with the "party mode" cycling 3 times before ending, id like it to go forever until i press either a different button or the starting button.

The "party mode" should already repeat as long as "results.value" still has the value 0xFF4AB5. Does Serial Monitor show some input AFTER it shows FF4AB5?

You left out the "break:" after the "Party Mode" case but it will just drop through into "Off" which won't last long until the "Party Mode" repeats.

the only things in the serial monitor are

FF4AB5
FFFFFFFF

then the "party mode" loops 2 times then stops as per my code. what i also tried to do was to put another

case 0xFF52AD:
i=3;

at the of the loop to try to make it stop that way but that just ended up stopping to loop after 1 cycle and not when i pressed 0xFF52AD

So where is the "FFFFFFFF" coming from? That is what is keeping your "Party Mode" from repeating forever.

I believe the FFFFFFFF is just stopping the remote from doing the same button press multiple times while you hold it, if i do it very fast it will not show up and if i hold a button down it will do multiple of FFFFFF. Is there a different type of loop i could use that doesn't count but instead waits for a button press to stop looping.

So 0xFFFFFFFF is a 'repeat' code. To get the last button to continue when you get the repeat code, store the button code and restore it when you get the repeat code:

void loop()
{
  unsigned long lastValue = results.value;


  if (irrecv.decode(&results))
  {
    Serial.println(results.value, HEX);  // Use HEX or DEC
    irrecv.resume(); // Receive the next value
  }


  switch (results.value) {
    case 0xFFFFFFFF:
      results.value = lastValue;
      break;


    case 0xFF30CF:                  // when button 1 is pressed only red will turn on
      digitalWrite(redpin, HIGH);
      digitalWrite(greenpin, LOW);
      digitalWrite(bluepin, LOW);
      break;


    case 0xFF18E7:                 // when button 2 is pressed only blue will turn on
      digitalWrite(bluepin, HIGH);
      digitalWrite(greenpin, LOW);
      digitalWrite(redpin, LOW);
      break;


    case 0xFF7A85:                // when button 3 is pressed only green will turn on
      digitalWrite(greenpin, HIGH);
      digitalWrite(redpin, LOW);
      digitalWrite(bluepin, LOW);
      break;


    case 0xFF10EF:                // when button 4 is pressed only leds red and blue will turn on
      digitalWrite(redpin, HIGH);
      digitalWrite(bluepin, HIGH);
      digitalWrite(greenpin, LOW);
      break;


    case 0xFF38C7:                   // when button 5 is press only leds blue and gree will turn on
      digitalWrite(greenpin, HIGH);
      digitalWrite(bluepin, HIGH);
      digitalWrite(redpin, LOW);
      break;


    case 0xFF5AA5:                 // when button 6 is press only leds green and red will turn on
      digitalWrite(greenpin, HIGH);
      digitalWrite(redpin, HIGH);
      digitalWrite(bluepin, LOW);
      break;


    case 0xFF42BD:                  // when button 7 is pressed all led colours will be on
      digitalWrite(greenpin, HIGH);
      digitalWrite(redpin, HIGH);
      digitalWrite(bluepin, HIGH);
      break;


    case 0xFF4AB5:  //starts "party mode" when button #8 is pressed and will run through each colour combo untill i=3
      digitalWrite(redpin, HIGH);
      digitalWrite(greenpin, LOW);
      digitalWrite(bluepin, LOW);
      delay (250);
      digitalWrite(redpin, LOW);
      digitalWrite(greenpin, HIGH);
      digitalWrite(bluepin, LOW);
      delay (250);
      digitalWrite(redpin, LOW);
      digitalWrite(greenpin, LOW);
      digitalWrite(bluepin, HIGH);
      delay (250);
      digitalWrite(redpin, HIGH);
      digitalWrite(greenpin, HIGH);
      digitalWrite(bluepin, LOW);
      delay (250);
      digitalWrite(redpin, HIGH);
      digitalWrite(greenpin, LOW);
      digitalWrite(bluepin, LOW);
      delay (250);
      digitalWrite(redpin, LOW);
      digitalWrite(greenpin, HIGH);
      digitalWrite(bluepin, HIGH);
      delay (250);
      digitalWrite(redpin, HIGH);
      digitalWrite(greenpin, HIGH);
      digitalWrite(bluepin, HIGH);
      delay (250);
      break;


    case 0xFF6897:                        // ALL OFF (Stop button)
      digitalWrite(greenpin, LOW);
      digitalWrite(redpin, LOW);
      digitalWrite(bluepin, LOW);
      break;


  }
}

The only thing i would want to try and do is to be able to press 0xff4ab5 and for:

digitalWrite(redpin, HIGH);
digitalWrite(greenpin, LOW);
digitalWrite(bluepin, LOW);
delay (250);
digitalWrite(redpin, LOW);
digitalWrite(greenpin, HIGH);
digitalWrite(bluepin, LOW);
delay (250);
digitalWrite(redpin, LOW);
digitalWrite(greenpin, LOW);
digitalWrite(bluepin, HIGH);
delay (250);
digitalWrite(redpin, HIGH);
digitalWrite(greenpin, HIGH);
digitalWrite(bluepin, LOW);
delay (250);
digitalWrite(redpin, HIGH);
digitalWrite(greenpin, LOW);
digitalWrite(bluepin, LOW);
delay (250);
digitalWrite(redpin, LOW);
digitalWrite(greenpin, HIGH);
digitalWrite(bluepin, HIGH);
delay (250);
digitalWrite(redpin, HIGH);
digitalWrite(greenpin, HIGH);
digitalWrite(bluepin, HIGH);
delay (250);

to loop "forever" until a button is pressed(off of the infrared remote). after the button is pressed id want it to break the cycle/loop and stop the led's and let me go back to the main program.

Solventsoap:
The only thing i would want to try and do is to be able to press 0xff4ab5 and for:

Party Mode

to loop "forever" until a button is pressed(off of the infrared remote). after the button is pressed id want it to break the cycle/loop and stop the led's and let me go back to the main program.

Yes. That is what the loop() that I just posted should do when you put it in place of your existing loop(). Try it.

IT WORKS THANK YOU SO MUCH!