Using a remote to break a loop

Hello, I'm pretty new to the Arduino world and know just enough to get myself in trouble. I'm attempting to make a series of 4 LEDs light up in a chasing pattern. I want to use a remote to control them.

I have been successful at turning them on with the remote, but I have tried and looked everywhere to figure out how to make them stop at the press of another button and then await another button command. Right now they will run forever and the only way I can turn them off is by disconnecting the power.

Can anyone out there point me in the right direction? I apologize in advance if I have posted in the wrong section.

Here is my code:

#include <IRremote.h>
 
int RECV_PIN = 8; // IR signal in to this pin
int pinled13 = 13; // 4th led from center
int pinled12 = 12; // 3rd led from center
int pinled11 = 11; // 2nd led from center
int pinled10 = 10; // 1st led from center
int pinled9 = 9; // Case / Time Travel LEDs
int i = 0;
typedef int bool;
#define true 1
#define false 0
bool exec_bool = 1;
int tim = 22;
// code received from "OK" Button
#define code1 0xFF02FD
#define code9 0xFF5AA5
IRrecv irrecv(RECV_PIN);
 
decode_results results;
 
void setup()
{
  irrecv.enableIRIn();  // Start the receiver
  pinMode(pinled13, OUTPUT);
  pinMode(pinled12, OUTPUT);
  pinMode(pinled11, OUTPUT);
  pinMode(pinled10, OUTPUT);
  pinMode(pinled9, OUTPUT);
   
   }
 
void loop() 

{

  if (irrecv.decode(&results)) {
    unsigned int value = results.value;
    switch(value) 
    {
       case code1:
         while(exec_bool = 1) {
          //digitalWrite(pinled9, HIGH);
          digitalWrite(pinled13, HIGH);
          delay(tim);
          digitalWrite(pinled13, LOW);
          delay(tim);
          digitalWrite(pinled12, HIGH);
          delay(tim);
          digitalWrite(pinled12, LOW);
          delay(tim);
          digitalWrite(pinled11, HIGH);
          delay(tim);
          digitalWrite(pinled11, LOW);
          delay(tim);
          digitalWrite(pinled10, HIGH);
          delay(tim);
          digitalWrite(pinled10, LOW);
          delay(tim); 
          irrecv.resume(); 
               
         }
         break;
       case code9: // #9 Button
        {exec_bool = 0;}
       
        break;
    }
    
    Serial.println(value); // you can comment this line
    irrecv.resume(); // Receive the next value
  }
}

by adding counters to ir sensor state

this should help https://www.arduino.cc/en/Tutorial/StateChangeDetection

while(exec_bool = 1) {

while(exec_bool == 1) {
:wink:

How do you get out of the 'while' ?

.

If you want a responsive program you MUST get rid of all the delay()s and use millis() to manage timing without blocking. See the demo Several Things at a Time

You also need to structure your program so it continually checks the buttons. Think of the child in the back of the car calling out "are we there yet?"

...R

I was able to get my lights to blink with milis(), but they all just blink off and on and the same time and I would like they to have chasing sequence, I can seem to wrap my head around that without using a delay, and advice??

A chasing sequence suggests to me that when one part ends it resets the timing for the next part. Something like
i

f (millis() - partOneStart >= partOneTime) {
  // end part1
  partTwoStart = millis()
}
if (millis() - partTwoStart >= partTwoTime) {
  // etc etc
}

...R

Im having a really hard time wrapping my head around this, I have already written a bunch of other code , that will cycle through the loop a set amount of time and ends, does anyone know if there is ANY way to exit a while loop with an IR signal without having to re-write all of my other code. Feeling defeated for today...

does anyone know if there is ANY way to exit a while loop with an IR signal without having to re-write all of my other code.

You take no shortcuts when writing code.
If it's not right then it's not right.

Write your sketch correctly in the first place.
Don't get defeated, enjoy the process.
If not, software isn't for you, move on to something else.

.

I totally understand, prop making is my hobby and I'm good at that...haha but I need the lights on my prop to work right. For now I wired in a reset button, until I get the code figured out...

Post your current sketch as it is now.

.