lcd.print : Code going screwy

I've been working on some code for a few weeks now for a project i'm working on, a DIY aquarium controller. I have my arduino hooked up to a breadboard on which it's wired up to an i2c RTC, LCD (2x16) Display (using 4bit LCD library), LM35 temp sensor and a number of tactile switches.

Basically I have one of the switches configured up as a menu button, each time it's pressed it displays a different information some of which can be manipulated by pressing the various buttons etc.

I'd finished all the code and ironed out all the bugs and decided i'd tidy up the layout of each of menu's, change things about on certain menu's etc.

It was when I started doing this that all kinds of weird things started to happen.

simple commands like lcd.print("OPTIONS "); wouldn't output correctly to the display, it would display "OPTION " ie, two spaces after it, without the S!

Another simple one like lcd.print("PROGRAM "); would output PROGRA|| where the M was replaced by an odd double pipe character.

Othertimes it evens stops the tactiles switches working altogether!

Another bizarre happening is that my code monitors a temp sensor and is supposed to report if the temp exceeds 29C. This it does fine but if I start adding or changing lcd.print statements it starts reporting the max temp has been exceed even though it hasn't. The code even proves it hasn't as part of the message reports the temp as 21C ! :smiley:

I've been at this one for several hours now and i'm stumped. I've tried using lcd.clear() and lcd.home(); before anything is sent to the display but it hasn't helped.

Could I be running out of memory perhaps? When I upload the code the software says 11274 bytes (of a 14336 byte maximum). Does the LCD take additional memory when loaded into the ATMEGA168 ?

I'm currently using 0017 arduino software

Any help much appreciated. :slight_smile:

Looks like i'd run out of memory as I suspected, specifically SRAM.

After searching around I found a link to this which helped me figure out how to tweak the code to save space.