It is OK to write out serial data with nothing connected.
In case (2) "Arduino + USB interface chip", the arduino has no idea if anything is connected or listening to the serial port. The code will transmit the bytes and act exactly the same whether plugged in to anything or not.
In case (1) "arduino with built in USB" it has some idea, but just drops bytes that are going to be transmitted when the USB port is not connected.
Hardware serial (case 2) has an output buffer, but that just makes the program a little faster. When the buffer is empty, a call to serial.{print, write}
will place bytes in the buffer and move on. When it's full, Serial.{print,write}
will wait until there is enough room to put the rest of the message in the buffer and move on. The hardware UART and interrupts it generates will keep taking bytes out of the buffer and transmitting them at a constant rate whether something is plugged in or not. In any case, the buffer is a fixed size and will never overflow.
As far as I can tell USB-Serial (case 1) only buffers incoming data. Since the calls to Serial.{print, write}
do nothing when not connected, they may take less time than they would otherwise. If your code is really unsafe about timing, that could cause a problem, but I doubt it will.
Many examples that come with the Arduino IDE have the following bit of code that pauses native USB Arduino-compatibles until the USB connection is initialized:
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
This code stops the Arduino from doing anything until the USB cable is connected.
Comment out or delete those 3 lines if you want the Arduino to run "stand-alone" without a USB cable connection (Arduino Cookbook p. 117) --
after you delete those lines, if you later plug in a USB cable, the USB will initialize correctly, and then you will see on your serial monitor everything printed by any later Serial.print() commands that run. (Tested on a Teensy LC).