An Arduino skectch can write to the Serial Monitor in the IDE.
Call functions Serial.print() and Serial.println().
The serial port must first be opened. Look at the source code of this skecth to see how that
is done in setup().
To use the sketch, open up the Arduino IDE application on the laptop or desktop computer connected
to the Arduino via USB.
Use the Tools menu in the IDE to select the port and the type of Arduino you are using. Open
the IntroducingSerial.ino sketch.
When you use the Arduino IDE on a laptop or desktop to run the sketch, the Arduino uses Serial.read() to
read from the computer keyboard and write to a window inside the IDE called Serial Monitor.
When you upload the sketch, the IDE uses the USB connection to send the program to the the Arduino.
Once the sketch is loaded into the Arduino, the USB connection is used differently. The sketch sends
and receives data through it. Inside the IDE is a window, the Serial Monitor. Open it with the
Tools menu. When the sketch writes into the serial port, the characters appear in the Serial Monitor.
When you type into the Serial Monitor, the characters go to the Arduino for the sketch to read.