What's up,
i've got a problem with my arduino code and i would like some help with it, here is the code.
/* const long (name) = (Code from sm);
*
* case (name):
* (Command);
* break;
*/
const long tvradio = 596423;
const long Source = 540863;
const long Power = 524543;
const long One = 573503;
const long Two = 532703;
const long Three = 565343;
const long Four = 549023;
const long Five = 581663;
const long Six = 528623;
const long Seven = 561263;
const long Eight = 544943;
const long Nine = 577583;
const long Zero = 536783;
const long List = 569933;
const long Guide = 579623;
const long Back = 557693;
const long Exit = 551063;
const long Up = 559223;
const long Down = 567383;
const long Left = 542903;
const long Right = 534743;
const long Ok = 575543;
const long Red = 538823;
const long Green = 571463;
const long Yellow = 546983;
const long Blue = 555143;
const long Chless = 585743;
const long Chmore = 526583;
const long Vless = 525053;
const long Vmore = 587783;
const long Menu = 553103;
const long I = 574013;
const long Mute = 530663;
const long Bottomone = 554633;
const long Bottomtwo = 562793;
const long Bottomthree = 553613;
const long Bottomfour = 538313;
const long Bottomfive = 546473;
const long Bottomsix = 566873;
#define red_pin 6
#define green_pin 5
#define blue_pin 3
#define RECV_PIN 10
#define IR_VCC 12
#define IR_GND 13
#define GND 4
#include <IRremote.h>
#include <LiquidCrystal.h>
const int rgb_leds[] = { 6, 5, 3 };
LiquidCrystal lcd(12,11,5,4,3,2);
int red = 255;
int green = 255;
int blue = 255;
int delay1(2000);
int delay2(10);
int backlight(9);
int Motor(7);
boolean running = true;
byte Boat[8] = {
0B00000,
0B00100,
0B01100,
0B11100,
0B00100,
0B11111,
0B01110,
0B00000
};
byte Heart[8] = {
0B00000,
0B01010,
0B11111,
0B11111,
0B11111,
0B01110,
0B00100,
0B00000
};
byte Arrow[8] = {
0B00000,
0B00000,
0B10000,
0B11100,
0B11111,
0B11100,
0B10000,
0B00000
};
void Lighttoggle() {
if(digitalRead(backlight) == LOW) //This toggles the statLED every time power button is hit
digitalWrite(backlight,HIGH);
else
digitalWrite(backlight,LOW);
}
long ir_signal;
IRrecv irrecv(RECV_PIN);
decode_results results;
void LEDblink() {
digitalWrite(8,HIGH);
delay(300);
digitalWrite(8,LOW);
delay(300);
}
void setup() {
pinMode( red_pin, OUTPUT );
pinMode( green_pin, OUTPUT );
pinMode( blue_pin, OUTPUT );
pinMode( GND, OUTPUT );
pinMode(IR_VCC,OUTPUT);
pinMode(IR_GND,OUTPUT);
digitalWrite(IR_VCC,HIGH);
digitalWrite(IR_GND,LOW);
digitalWrite(GND,HIGH);
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
lcd.begin(8, 2);
lcd.createChar(1,Boat);
lcd.createChar(2,Heart);
lcd.createChar(3,Arrow);
}
void loop() {
if ( irrecv.decode(&results) ) {
ir_signal = results.value;
Serial.println( ir_signal );
switch (ir_signal) {
case 16580863:
LEDblink();
loop();
break;
}
ir_signal = 0;
irrecv.resume(); // Receive the next value
}
}
everything works like it's supposed to except the following.
void LEDblink() {
digitalWrite(8,HIGH);
delay(300);
digitalWrite(8,LOW);
delay(300);
}
void loop() {
if ( irrecv.decode(&results) ) {
ir_signal = results.value;
Serial.println( ir_signal );
switch (ir_signal) {
case 16580863:
LEDblink();
loop();
break;
}
When i press the button on the remote, the led starts blinking and the "LEDblink" code keeps repeating.
The problem here is:
when the led blink starts repeating, i can't stop it and i cant use any other button
How do i add a button or a function that allows me to stop the loop and use other buttons again.
(i want to use this for RGB lights. i want to be able to get green light, or red, AND i want a cross fader, but i cant exit the fader)
pls help me