Menu system with Strange behavior

Hi All
I am totally new to the world of Arduoino, so please take it easy with me !

I have written this menu system to control drip production using a solenoid valve. All was going well until I first connected my Uno to the hardware. After disconnection, I added some more code
and have been getting unexpected freezes and occasionally a whole heap of garbage sent to Hyper Terminal ever since.

Currently with the code as is, if I put the commented line into DislpayBottomMenu(), then after 1 pass through the loop() execution stops (or serial comms does anyway).
If I enable the call to DislpayBottomMenu() in setup(), half of the first line if DislpayBottomMenu() makes it up the comm port then freezes or stops!!!

void DisplayBottomMenu()
{
  Serial.print("==================MENU=====================\r\n");
  Serial.print("1 Alter Trigger delay (Currently " ); Serial.print(Trigger_Delay,DEC);Serial.print(" ms)\r\n");
  Serial.print("2 Alter Solenoid Actuation delay (Currently "); Serial.print(SolenoidActuation_Delay,DEC); Serial.print(" ms)\r\n");
  Serial.print("3 Alter Drip delays (Currently "); Serial.print(SequenceDrip_Delay[0],DEC); Serial.print(" and ");Serial.print(SequenceDrip_Delay[1],DEC);Serial.print(" ms)\r\n");
  Serial.print("4 Alter Number of Drips in Sequence (Currently "); Serial.print(DripsInSequence,DEC); Serial.print(")\r\n");

// =========== PROBLEM ADDING THIS LINE
//   Serial.print("5 Alter Drip Formation Time (Currently "); Serial.print(DripFormationTime,DEC); Serial.print(")\r\n");
  
  Serial.print("D Show Current Variable Values"); Serial.print("\r\n");
  Serial.print("R Start");Serial.print("\r\n"); 
  Serial.print("S Stop"); Serial.print("\r\n");
  Serial.print("F Flush the serial port buffer"); Serial.print("\r\n");
  Serial.print("C Clear the Screen"); Serial.print("\r\n");
  MenuLevel = 0;
 }

I cant see ANY pattern to the errors Im getting, they seem totally random.

The .ino file is attached.

I’d be Very grateful for any help or ideas as to how to proceed.

Incidentally, what stand alone debug tools are best for sketch coding ??

Thanks
Phil

simple_serial_4.ino (11.4 KB)

The usual cause is running out of RAM.
See if you can move some of those strings into PROGMEM

Also, if you've got a solenoid, check that it is fitted with a snubber diode and that everything is decoupled.

At a quick glance, I'd say you were running out of SRAM. It's very difficult to read though, because you have so many multi-statement lines. Please try to stick to one statement per line.

As you are using IDE 1.0, try changing all the Serial.print() statements to use the F() macro, which keeps the text in flash, rather than copying it into SRAM.

For example:

  Serial.print("==================MENU=====================\r\n");

becomes

  Serial.print(F("==================MENU=====================\r\n"));

Guys
Thanks for the quick reply.
I recon your right about running out of RAM. I have written software for years for the PC using Visual Studio... Ive been told its 'bloat ware' by people used to developing for micros lol.
Time to start thinking about it !!!
Ill try moving the text and see what happens.
Cheers

Thanks So much,
Ive been beating my head against that for several hours !
Ive assigned any text that I can to Flash memory.
Seems to be working ok now

Cheers
Phil