I have a problem when having many if statement to check incoming characters from serial.read combined with Serial.print command.
The problem is I'm unable to check for characters. It seems the Serial buffer has an overflow.
The combination having loaded libraries and many if statement, seems to be a problem.
Without loading any library it works well. But if I try to load ex. library ethernet.h, the serial incoming characters ignores or give me a random output. (see attached code).
But if I reduce the if statement and Serial.println lines, ex. remark #help, I can get it work.
After removing the delay(2000), I still have same problem. As explained if I remove lines where Serial.print occurs, I can get it works. It works when I remark the "#help" function, but when unremark or add more Serial.print lines, the Serial read does not work. Is there some kind of limitation for Serial.print and characters?
It sounds to me like you are running out of memory and the fact that it works if you comment out the #help function with its multitude lines of text would also point to that. Your use of Strings will also contribute to any memory problem as it serves to fragment the available memory.
First, I removed the duplicated lines, still same problem. To recap my problem:
The program runs fine without any library loaded. I can have as many Serial.print line as I needed. But when i ex. load a library ethernet.h and add just few Serial.print "text...", I'm unable to check incomming characters. The monitor returns only first Serial.print line. I can reduse Serial.print lines and/or printed text, to get it work again.
FYI the memory uses is beyond limit <32.000K (typical 20K used).
I may have RAM problem. If so, is there any possibility to clear RAM after serial reading characters successful?
I can reduse Serial.print lines and/or printed text, to get it work again.
Does this mean that if you reduce the number of strings it works? If so you have the answer to your problems several times above.
You didn't answer two questions about the chip you are using , but we can assume it's a Mega328 as you said 32k of program memory. So that's less than 2k of RAM available to your program, you will use that up in no time.