We are a couple of dudes who have a big problem. We are creating an interface of several menus using the LCD Library but we have now reached a limit for how many different printlines we can have in the source code. We are not printing these lines in the on the same time, but if we create too many different printlines the program simply chrashes, even though the added printlines arent even the one being loaded. We still have a lot of space left on the Arduino. So any ideas to what can be wrong or a solution to the probelm?
Our code is plus a 1000 lines long so it won´t make much sense posting it when the problem is not a specific code but adding any more code of lcd.print(" ......"); which causes the chrash.
So, the download works fine and the Arduino starts up? Random things on the display doesn't sound like a crash necessarily.
Have you tried replacing all the lcd.print() with Serial.print()? That should let you know if it's a size issue, and if the "random" characters are the same out the serial port.
We are printing on a simple 20x4 LCD display, we are not printing in the serial port. So yeah it is the LCD display that prints, some times different prints on the same time mingled into each other (when it fails), or it prints nothing but squares (when it fails).
Yes, but if you replace all calls to lcd.print() with Serial.print() and you still have the problem, then it's a probably a general size issue. Plus, you get to see what order the prints are coming out in, and where it might be going wrong.
What size is the sketch download saying the total filesize is?
When i tried changing all the lcd to serial prints nothing happened if there were "too many" prints but if i commented 2 prints out again it worked just fine.
THe sketch size is around 16.000 bytes right now. The maximum size for the arduino should be around 32.000 bytes, so the general size shouldn´t really not be a problem
There's only 2k of static ram on an arduino uno. Each use of "..." in a print takes up static ram. You need to either combine then into a function call, or put the strings in PROGMEM and use the variable in the print instead.
Yep it definitely looks like the static memory problem.
I would put all your strings in a table in PROGMEM. That'll free up static memory, but it will also make your code a lot simpler as you won't be duplicating all your LCD setup commands.
The simplest solution would be to use PROGMEM as suggested above.
If you are using Arduino IDE 1.0, you can replace lcd.print("your text"); with lcd.print(F("your text"));
F() is a macro to ease the use of PROGMEM and give it a more natural feel.