PROBLEM
I have the problem that the Serial Monitor is not functional (no incoming data or unknown result) when I provided too many if, else if (more than 3 if, else if **below code "misubishi() Function") . However,when I comment some of it out everythings work fine!
NOTE
I have already set Baud Rate @ 57600, also the same with Serial.Begin()
I have already test all if and else if statement work.
my board is Arduino Uno.
Binary sketch size: 14,478 bytes (of a 32,256 byte maximum).
EDIT
Added All Code in problem sketch. - 6/13/2014
Added Answer - 7/13/2014
Deleted Unnecessary Code...
ANWSER
This is a solution for my case, it's about use of memory (SRAM)
problem in mitsubishi() that I assign many unsigned int code[] and it over SRAM limit
use of PROGMEM instead
so, it is not about TOO Many If, else if .
REF.
http://forum.arduino.cc/index.php?topic=201031.0
misubishi() FUNCTION
void mitsubishi(char* data){
int khz=38;
if (strcmp((char*)msg,"off") == 0)
{
// Serial.println("send -> OFF");
unsigned int code[] = {3150,1550,999,999,999,1111,450,000,999,999,999,1200,999,999,999,1111,999,999,999,999,999,1111,999,1200,999,1200,999,000,999,1200,999,999,999,1111,999,1200,999,1200,999,000,999,999,999,999,999,999,999,1111,999,1200,999,999,999,1111,999,1200,999,999,999,999,999,1111,999,999,999,999,999,1111,450,000,999,999,999,1200,999,1111,999,999,999,1200,999,1111,999,1200,999,1111,450,1111,999,1200,999,000,450,1111,999,999,999,1111,450,000,999,999,999,999,999,999,999,1111,999,999,999,1200,999,999,999,1111,999,1200,999,1111,999,1200,999,1200,999,000,999,999,999,1200,999,999,999,000,999,999,999,999,999,999,999,1111,999,1200,999,999,999,999,999,1111,999,1200,999,1111,450,1111,999,999,000,1200,450,000,999,1200,999,999,999,000,450,000,999,999,999,1200,999,000,450,1111,999,1000};
irsend.sendRaw(code,sizeof(code)/sizeof(int),khz);
}
else if (strcmp((char*)msg,"on/27") == 0)
{
// Serial.println("send -> ON, @ 27 degree");
unsigned int code[] = {3200,1550,999,000,450,1111,450,000,450,000,999,1111,450,000,450,1111,999,000,450,000,450,1111,450,1111,999,1111,450,000,450,1111,999,000,450,1111,450,1111,999,1111,450,000,450,000,999,999,999,000,450,1111,450,1111,999,000,450,1111,450,1111,999,000,450,000,450,1111,999,999,999,000,450,1111,450,000,999,999,999,1111,450,1111,999,999,999,1111,450,1111,999,1111,450,1111,450,1111,999,1111,450,000,450,1111,999,000,450,1111,450,000,999,999,999,000,450,000,450,1111,999,999,999,1111,450,000,450,1111,999,1111,450,1111,999,1111,450,1111,999,1200,999,1111,450,1111,999,999,999,000,450,000,450,000,450,000,999,999,999,000,450,000,450,000,450,1111,999,1111,450,000,450,1111,999,000,450,1111,450,000,450,1100,450,000,450,000,450,1111,999,999,999,1111,450,000,450,1111,999,1000};
irsend.sendRaw(code,sizeof(code)/sizeof(int),khz);
}
else if (strcmp((char*)msg,"on/26") == 0)
{
// Serial.println("send -> ON, @ 26 degree");
unsigned int code[] = {3150,1550,999,999,450,1111,999,000,450,000,450,1111,999,999,999,1111,999,999,999,999,999,1111,999,1200,999,1200,999,000,999,1200,999,999,999,1111,999,1200,450,1111,999,000,999,999,999,999,999,999,999,1111,450,1111,999,999,999,1111,450,1111,999,999,999,999,999,1111,450,000,450,000,999,1111,450,000,450,000,450,1111,999,1111,450,000,450,1111,999,1111,450,1111,999,1200,999,1111,450,1111,999,999,999,1111,450,000,450,1111,999,000,450,000,450,000,450,000,999,1111,450,000,450,1111,999,999,999,1111,450,1111,999,1111,450,1111,450,1111,999,1111,450,1111,999,1111,450,000,450,000,450,000,999,999,999,000,450,000,450,000,999,999,999,999,999,1111,999,1200,999,1111,999,999,999,1200,999,1111,999,999,999,1200,999,999,999,000,999,999,999,1200,999,999,999,000,999,1200,999,1000};
irsend.sendRaw(code,sizeof(code)/sizeof(int),khz);
}
else if (strcmp((char*)msg,"on/25") == 0)
{
// Serial.println("send -> ON, @ 25 degree");
unsigned int code[] = {3200,1550,999,000,450,1111,450,000,999,999,999,1111,450,000,450,1111,999,000,450,000,450,1111,450,1100,450,1111,450,000,450,1100,450,000,450,1111,450,1100,450,1111,450,000,450,000,999,000,450,000,450,1111,450,1111,999,000,450,1111,450,1111,999,000,450,000,450,1111,999,999,999,000,999,1200,999,999,999,999,999,1111,999,1200,999,999,999,1111,999,1200,999,1111,450,1111,999,1200,999,1111,999,999,999,1200,999,000,999,1200,999,999,999,999,999,000,999,999,999,1200,999,999,999,1111,999,999,999,1200,999,1111,999,1200,999,1111,450,1111,999,1200,999,1111,450,1111,999,999,999,000,450,000,450,000,450,000,999,999,999,000,450,000,450,000,450,1111,999,1111,450,000,450,1111,999,1111,450,1111,999,999,999,1111,450,000,450,000,999,1200,999,000,450,000,450,000,450,1111,999,1000};
irsend.sendRaw(code,sizeof(code)/sizeof(int),khz);
}
else if (strcmp((char*)msg,"on/20") == 0)
{
// Serial.println("send -> ON, @ 20 degree");
unsigned int code[] = {3200,1500,450,000,450,1111,450,000,999,000,450,1111,450,000,450,1100,450,000,450,000,450,1111,999,1111,450,1111,450,000,999,1111,450,000,450,1111,999,1111,450,1111,450,000,999,999,999,000,450,000,450,1111,999,1111,450,000,450,1111,999,1111,450,000,450,000,450,1111,999,000,450,000,450,1111,999,999,999,000,450,1111,450,1111,999,000,450,1111,999,1200,999,1111,999,1200,999,1111,450,1111,450,000,999,1111,450,000,450,1111,999,999,999,000,450,000,450,000,450,1111,999,000,450,1111,450,000,450,1100,450,1111,450,1111,999,1111,450,1111,450,1111,999,1111,450,1111,999,999,999,000,450,000,450,000,450,000,999,999,999,000,450,000,450,000,450,1100,450,1111,450,000,450,000,999,999,999,1111,450,1111,999,1111,450,000,450,000,450,1111,999,1111,450,1111,999,999,999,000,450,1000};
irsend.sendRaw(code,sizeof(code)/sizeof(int),khz);
}
else if (strcmp((char*)msg,"info") == 0)
{
// Serial.println("send -> Fetch Temperature Info.");
steps();
radio.startListening();
}
else
{
// Serial.println("send -> Nothings.");
}
}