Sketch only works when IDE monitor is active?

I have a sketch that works fine when connected to IDE, but if I shut down the IDE (or even just the monitor window) it soon fails (LED stops blinking). If I hit reset without IDE monitor connected it doesn't startup and run properly (LED never blinks).

This program does report to monitor quite a bit, but my understanding was the serial comms simply goes to the "bit bucket" if monitor not connected.

What am I missing?

The TX and RX LEDs are controlled by the drivers in the PC not by the data lines on the arduino. Your sketch is still running.

I know what you mean by the TX/RX leds, but when my sketch runs it executes the code I added to change the state of the LED on D13 every loop. So the LED blinking confirms sketch running.

But that LED doesn't flash, or soon stops, unless the serial monitor is connected/active, & even if I reset

my question remains, how / why ... ?

I think posting your code and maybee a schematic of your project would make it a lot easier to help.

Yes post the sketch.

But that LED doesn't flash, or soon stops, unless the serial monitor is connected/active, & even if I reset

When the serial monitor is connected and disconnected it automatically resets the arduino, so is there something in the sketch that needs the serial port before you get to flash the LED?

Basically what you suggest does not happen so we need to find out where you are misunderstanding things.

After some testing it’s nothing to do with Serial monitor being connected. Disabling sections of code until the LED worked normally, the problem seems to be due to a conflict between the SD library and the D13 LED. When I comment the 3rd line out (SD.begin) from this section it works, when I reinstate that line only the LED doesn’t work again: (bizarre!)

displayText(1); // “Initializing SD card…”
pinMode(SS_pin, OUTPUT); // must be set as an output or the SD library won’t work.
if (!SD.begin(SS_pin)) {displayText(2); return;} // “[SD init FAILED]”
displayText(3); // “[SD OK]”
root ="/");
printDirectory(root, 0);

(BTW displayText only prints text stored using PROGMEM)

I’ve attached a ZIP of the full sketch (6 tabs, compiles to approx. 26,000 bytes). I’m running this in a Freetronics USBdroid (a Uno compatible).

Meanwhile I’ll try a stripped down program with just SD aspects and D13 LED to see if this still happens. (6 KB)

If that device is an Uno-type (not Mega), then that is normal. Pins 11-13 are used for the SPI interface. That is what the SD interface uses for communication.

edit: That should have been digital pins 10-13. Pin 10 is the default slave select, so you can't use it either.

thanks SurferTim, that explains it.
I may have to dump the blinking LED, runnig out of pins!