SITUATION: The Arduino is connected to a computer. The Arduino IDE is running and the Serial Monitor is open. The Arduino sketch contains Serial.print() and Serial.println() statements but the text is not appearing in the Serial Monitor.
STEP 1: Verify the Arduino and the Arduino IDE are connected to the same communications port. These can become separate if the Arduino is unplugged and plugged back in. A simple way to be certain the port is correct is by re-uploading the sketch from the same IDE that is used to open the Serial Monitor.
STEP 2: Verify the Serial Monitor on the computer and the Serial Port on the Arduino are set to the same data rate. The data rate is often referred to as the baud rate.
- The data rate for the Arduino's serial port is set by the Serial.begin(<datarate>) programming statement, usually found in the setup() method. For most Lessons the data rate is 9600, in which case the programming statement is Serial.begin(9600);
- The data rate for the Serial Monitor is set by selecting a value from the dropdown box in the lower-right corner. For most lessons this is set to 9600 baud.
- Verify the data rate specified in the Serial.begin() statement is the save value as the data rate set for the Serial Monitor.
STEP 3: Closely examine the Arduino sketch. Be certain the Serial.begin() programming statement is being executed. If it is not then the Serial Port will not function.
STEP 4: Closely examine the Arduino sketch. Be certain the Serial.print() and Serial.println() statements are being executed. Sometimes a branching statement, such as if and else, will cause these statements to be missed.
STEP 5: Check the Serial.print() and Serial.println() statements for syntax errors. Since print and println are common among several programming languages sometimes a usage that is valid in one doesn't work with the Arduino. An example of a syntax error is,
Serial.print("Hello, " + "world!"); // WARNING! DOES NOT WORK
String concatenation does not work with the Arduino. Refer to the language reference for more information at http://arduino.cc/en/Reference/StringObject for specifics.
STEP 6: Examine both the Arduino sketch and the wiring of any circuit connected to the Arduino. Make certain the digital pins 0 and 1 are not being used. Both are connected to the components on the Arduino that performs the serial text communication and may not be simultaneously used for something else.