Hi guys
I've been struggling with this problem few weeks now. Decided to try and get some help here. Hopw You have some ideas for me.
I'm trying to build a remote controls. It has 5 buttons:
4 buttons sending 4 different IR codes (via IR led of course)
The other button is shifting the codes. I mean - pressing the 5th with one of the 4 buttons will send different codes. I get 8 codes with 5 buttons.
Now, while I program (just to try) 5 codes - each for every button- Everything works wonderful. All is well.
When I try to program my real program - Some of the codes getting scrambled. I mean - some works just fine, but some send codes that make no sense.
Can anyone think of what can cause the problem?
#include <IRremote.h>
IRsend irsend;
#define CTRL 7 //blue
#define Up 12 //orange
#define Down 11 //purple
#define Next 9 //Green
#define Last 10 //Yellow
// setup the arrays for each code
unsigned int VolUp[135] = {
8400, 4140 , 580 ,1500 , 580 ,460 , 600 ,1500 , 580 ,1500 , 580 ,480 , 580 ,1500 , 580 ,460 , 580 ,1500 , 580 ,480 , 580 ,
1500 ,
I cut it here....you get the idea...
}; //total 135
unsigned int VolDown[135] = {
***I cut it here for the forum, because the codes are long and doesn't matter
}; //total 135
unsigned int NextTrack[135] = {
***
}; //total
unsigned int LastTrack[271] = {
***
}; //total 135
unsigned int NextFolder[135] = {
***
}; //total 135
unsigned int LastFolder[135] = {
***
}; //total 135
unsigned int Answer[135] = {
***
}; //total 135
unsigned int EndCall[135] = {
***
}; //total 135
void setup()
{
pinMode(CTRL, INPUT);
pinMode(Up, INPUT);
pinMode(Down, INPUT);
pinMode(Next, INPUT);
pinMode(Last, INPUT);
}
void loop()
{
if (digitalRead(Up) == LOW){ //Up is pressed
if (digitalRead(CTRL) == HIGH){ //CTRL is not pressed
irsend.sendRaw(VolUp,135,38); //Volume Up
delay (200);
}
if (digitalRead(CTRL) == LOW){ //CTRL is pressed
irsend.sendRaw(Answer,135,38); //Answer
delay(200);
}
}
if (digitalRead(Down) == LOW){ //Down is pressed
if (digitalRead(CTRL) == HIGH){ //CTRL is not pressed
irsend.sendRaw(VolDown,135,38); //Volume Down
delay (200);
}
if (digitalRead(CTRL) == LOW){ //CTRL is pressed
irsend.sendRaw(EndCall,135,38); //End Call
delay (200);
}
}
if (digitalRead(Next) == LOW){ //Next is pressed
if (digitalRead(CTRL) == HIGH){ //CTRL is not pressed
irsend.sendRaw(NextTrack,135,38); //Next Track
delay (200);
}
if (digitalRead(CTRL) == LOW){ //CTRL is pressed
irsend.sendRaw(NextFolder,135,38); //Next Folder
delay (200);
}
}
if (digitalRead(Last) == LOW){ //Last is pressed
if (digitalRead(CTRL) == HIGH){ //CTRL is not pressed
irsend.sendRaw(LastTrack,135,38); //Last Track
delay (200);
}
if (digitalRead(CTRL) == LOW){ //CTRL is pressed
irsend.sendRaw(LastFolder,135,38); //Last Folder
delay (200);
}
}
}


