Hello,
I've run into a little problem, which I hope somebody might be able to explain. I'm using an UNO Rev3 to send some RAW iR commands to a Samsung TV by means of the IRremote library. (Note: if anybody has a library that can send Samsung commands 'natively', I'll gladly revise the entire sketch!).
At the moment, I have the Channel 0 code configured as an integer array:
unsigned int iCode[68] = {
4650,4300,700,1550,700,1500,700,1550,700,400,700,400,700,400,700,450,650,450,650,1550,700,1550,650,
1550,700,400,700,400,700,400,700,450,700,400,700,1550,650,400,700,450,700,400,650,1550,700,400,700,
450,700,400,700,400,700,1500,700,1550,700,1500,700,400,700,1550,650,1550,700,1500,700};
irSend.sendRaw(iCode, 68, iFreq);
Serial.println("Executed TV CHAN 0 command.");
I also have the power on, power off, and few other codes defined. This works fine, but when I add the remaining numbers, the UNO hangs at boot, or at the latest when I try to execute any command. The other numbers are also defined in the same way. I won't bore you with the entire sketch, but here's an example:
if (striRCode == "tv000") {
unsigned int iCode[68] = {
4650,4300,700,1550,700,1500,700,1550,700,400,700,400,700,400,700,450,650,450,650,1550,700,1550,650,
1550,700,400,700,400,700,400,700,450,700,400,700,1550,650,400,700,450,700,400,650,1550,700,400,700,
450,700,400,700,400,700,1500,700,1550,700,1500,700,400,700,1550,650,1550,700,1500,700};
irSend.sendRaw(iCode, 68, iFreq);
Serial.println("Executed TV CHAN 0 command.");
}
if (striRCode == "tv111") {
unsigned int iCode[68] = {
4500,4450,600,1600,600,1600,600,1650,600,500,600,500,600,500,650,500,600,500,600,1600,600,1650,600,
1600,600,500,600,550,600,500,600,500,600,500,600,500,650,500,600,1600,600,500,600,550,600,500,600,
500,600,500,600,1650,600,1600,600,500,600,1650,600,1600,600,1650,600,1600,600,1600,600};
irSend.sendRaw(iCode, 68, iFreq);
Serial.println("Executed TV CHAN 1 command.");
}
if (striRCode == "tv222") {
unsigned int iCode[68] = {
4550,4400,600,1600,600,1650,600,1600,600,500,600,550,600,500,600,500,600,500,600,1650,600,1600,600,
1650,600,500,600,500,600,500,600,550,600,500,600,1600,600,500,600,1650,600,500,600,500,600,550,600,
500,600,500,600,500,600,1650,600,500,600,1600,600,1650,600,1600,600,1650,600,1600,600};
irSend.sendRaw(iCode, 68, iFreq);
Serial.println("Executed TV CHAN 2 command.");
}
The 'striRCode' variable is taken straight from the serial input (me typing). What I don't understand is why the mere presence of the other arrays makes it unstable. After all, it only receives one command at a time, and if it didn't flush it's memory after performing a command, I would still expect the first one to work (even if I had to hit the reset button afterwards). If it was trying to put all the arrays in memory as soon as one command was executed, it would crash with only two commands defined, although I can cram in about 4 before it goes wrong. Additionally, that would also cause a compiler error as I use the name 'iCode' for every single array and that would cause conflicts.
The code above is in a separate function, not loop(). The loop() only grabs the serial input and hands it to the function containing all the integer arrays, etc.
If I only put in the codes for let's say channels 0 through 4, it also works - so the contents of the array aren't the problem either. Is there some black magic going on in the IDE that I'm not aware of?
Any help would be appreciated.
Kind regards,
PelliX