println works only up to a point.

I’m new to Arduino but my background is COBOL. As a result the code that I’m including may look odd to many of you. My goal was to create some code that causes LEDs to blink but to do it in such a way that the code displays where it is specific points. The light blinks when it’s supposed to but that’s not what a care about. I care about the trace displays and they work until the last one. A that point it’s supposed to display 123456789 but it only displays 12 and ignores the last 7 bytes.

I’ve tried getting rid of the COBOL like paragraph names and I’ve tried restructuring it in other ways. but no matter what I try, those last 7 bytes are always missing.

#include <stdio.h>
/* #include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); */

// WORKING STORAGESECTION
// const unsigned int BAUD_RATE = 9600;
int LED_PIN = 8;
int SHORT_PAUSE_TIME = 200;
int LONG_PAUSE_TIME = 1500;
char MISC_STRING[16] = " ";
String DISPLAY_TRACE = “Y”;
String YES = “Y”;

// PROCEDURE DIVISION
void setup()
{
pinMode(LED_PIN,OUTPUT);

Serial.begin(9600);

}

void loop()
{
A_MAINLINE_SECTION:
A010_MAINLINE:

B_INIT_SECTION:
B010_TEST_LED:
if (DISPLAY_TRACE == YES)
{Serial.println(" ");
Serial.println(“B010: init”); }

B015:
digitalWrite(LED_PIN, HIGH);
delay(SHORT_PAUSE_TIME);

digitalWrite(LED_PIN, LOW);
delay(SHORT_PAUSE_TIME);

delay(LONG_PAUSE_TIME);

B090:

F_SECTION:
F010:
if (DISPLAY_TRACE == YES)
{Serial.println(“F010: start”); }

digitalWrite(LED_PIN, HIGH);
delay(SHORT_PAUSE_TIME);
digitalWrite(LED_PIN, LOW);
delay(SHORT_PAUSE_TIME);

digitalWrite(LED_PIN, HIGH);
delay(SHORT_PAUSE_TIME);
digitalWrite(LED_PIN, LOW);
delay(SHORT_PAUSE_TIME);

delay(LONG_PAUSE_TIME);

F090:

G_SECTION:
G010:
if (DISPLAY_TRACE == YES)
{Serial.println(“G010: start”); }

digitalWrite(LED_PIN, HIGH);
delay(SHORT_PAUSE_TIME);
digitalWrite(LED_PIN, LOW);
delay(SHORT_PAUSE_TIME);

digitalWrite(LED_PIN, HIGH);
delay(SHORT_PAUSE_TIME);
digitalWrite(LED_PIN, LOW);
delay(SHORT_PAUSE_TIME);

digitalWrite(LED_PIN, HIGH);
delay(SHORT_PAUSE_TIME);
digitalWrite(LED_PIN, LOW);
delay(SHORT_PAUSE_TIME);

G090:

Z010_STOP_RUN:
if (DISPLAY_TRACE == YES)
{Serial.println(“123456789”); }

exit(0);

}

The exit(0) turns off interrupts. Interrupts are used to do serial prints. Instead use:

while (true) { }

Or you could do this before the exit:

Serial.flush ();  // flush outstanding output

Wow, I'm impressed.
I changed the exit statement and all is well.
Thank you.

String             YES = "Y";

I would advise you to try to get more into the C way of doing things. This is a slow and cumbersome way of doing a boolean. The "bool" type in C is much more efficient, and you can test like this:

      if (DISPLAY_TRACE)

Also in C by convention all caps is used for constants, and lower (or mixed) case for variables. You don't have to, but you'll confuse people if you post your code in the future. And I also advise you to not use labels (nor goto). May as well settle into a new paradigm.

I used to program in Cobol, I recognize what you are doing, but I think you will find things easier if you do things more the "C" way. :slight_smile:

PROCEDURE DIVISION

I remember COBOL too, but the intervening years have deadened the pain. :smiley:

The "section names" are completely pointless and add nothing to the sketch.
At first glance, one might think you had "goto"s in there {{{shudder}}}