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
}
}