Starting Electronics needs your help! Please make a donation to help cover our hosting and other costs. Click the donate button to send a donation of any amount.
Created on: 8 January 2022
Arduino serial monitor for beginners in electronics. Send and receive data between the serial monitor window on a computer and an Arduino. The serial monitor is a utility that is part of the Arduino IDE. Send text from an Arduino board to the serial monitor window on a computer. In addition, send text from the serial monitor window to an Arduino board. Communications between the serial monitor and Arduino board takes place over the USB connection between the computer and Arduino.
Part 4 of the Arduino Tutorial for Beginners
The above image shows text sent from an example sketch running on an Arduino. The big receive area of the serial monitor window displays text received from the Arduino board.
Part 2 of this Arduino tutorial for beginners shows how to install the Arduino IDE. In addition, it shows how to load an example sketch to an Arduino. It is necessary to know how to load a sketch to an Arduino board in this part of the tutorial. Therefore, first finish the previous parts of this tutorial before continuing with this part. A sketch loaded to an Arduino board demonstrates how the serial monitor works in the sub-sections that follow.
Start the Arduino IDE application. Select File → Examples → 04.Communication → ASCIITable from the top Arduino IDE menu bar. As a result, the ASCIITable example sketch opens in a new Arduino IDE window. Upload the ASCIITable example sketch to the Arduino Uno or MEGA 2560 board.
After the ASCIITable sketch is uploaded, nothing is seen to happen. This is because this example sketch sends text out of the USB port of the Arduino board. Because there is nothing running on the computer to receive this text, nothing is seen.
The following image shows the location of the serial monitor window icon on the Arduino IDE toolbar. A red dot near the top right of the image shows the serial monitor toolbar icon location.
Click the Serial Monitor icon near the top right of the Arduino IDE to open the serial monitor window. The above image shows the serial monitor window opened, and on top of the Arduino IDE window. Because the ASCIITable example is loaded on the Arduino board, when the serial monitor window opens, the Arduino sends text to the serial monitor window. This is also because opening the serial monitor window resets the Arduino board, causing the ASCIITable sketch to run from the beginning again.
The ASCIITable sketch sends text out of the USB port of the Arduino. Because the serial monitor is connected to the USB port, it receives the text and displays it in the big receive area of the window. As a result, text scrolls on the serial monitor window for a while. The text then stops because the Arduino has finished sending text. Use the right scrollbar in the serial monitor window to scroll up. Scrolling up reveals all of the text that the Arduino sent.
When junk, or garbage characters, or even nothing is displayed in the serial monitor, it is usually because of an incorrect baud rate setting. Look at the bottom of the serial monitor in the above image. Notice the value 9600 baud in a box. This is the baud setting of communications between the Arduino and serial monitor. The ASCIITable, and most other built-in example sketches, set the Arduino to communicate at 9600 baud. If your serial monitor window shows a different baud rate, change it to 9600 baud. Do this by clicking the baud drop-down list. Select 9600 baud on the list that drops down.
Press and release the RESET button on the Arduino board and the ASCIITable sketch runs from the beginning again. As a result of the reset, the same text scrolls down the serial monitor window and then stops again. The RESET button is the only push button on the Arduino Uno or MEGA 2560.
Pushing the RESET button in holds the board in reset. This means that the sketch currently loaded on the board stops running. Releasing the RESET button takes the board out of reset. As a result, the sketch currently loaded on the Arduino starts running from the beginning again.
The red dot in the image below shows the location of the Clear output button at the bottom of the serial monitor window. Click the Clear output button and text is cleared from the receive area of the serial monitor window. Reset the Arduino, and the receive area fills with text from the ASCIITable sketch again.
ASCII stands for American Standard Code for Information Interchange. ASCII is a standard way that uses numbers to represent various characters. For example, the decimal number 65 represents the letter A. Another example is the decimal number 125 represents a closing brace: }. This allows computers to send and receive text by sending and receiving numbers. For example when a computer receives the number 65, it knows to display the letter A.
The ASCIITable sketch sends the numbers 33 through to 126 out of the USB port. This results in the printable text characters from the ASCII table displayed in the serial monitor window. In addition to the ASCII characters, the number that represents each character is displayed. Each number is shown in four different numbering systems. These are the decimal, hexadecimal, octal and binary number systems. In the serial monitor window, these number systems are abbreviated to dec, hex, oct and bin.
See the Wikipedia article on ASCII for a lot more information on ASCII and the ASCII table.
This section shows how to send data from the serial monitor window to an Arduino board. Close the serial monitor window. Afterwards, select File → Examples → 04.Communication → PhysicalPixel on the top Arduino IDE menu bar. As a result, the PhysicalPixel example sketch opens in a new Arduino IDE window. Upload the PhysicalPixel sketch to the target Arduino board.
The PhysicalPixel sketch monitors the USB port. It waits for the letter H or L, and ignores all other letters if received. When it receives a capital letter H, it switches the Arduino on-board LED on. When it receives a capital letter L, it switches the on-board LED off. H stands for ‘high’, meaning a high voltage that switches the LED on. L stands for ‘low’, meaning a low voltage that switches the LED off.
Open the serial monitor window from the Arduino IDE as previously shown. After this, type the capital letter H into the top send text box of the serial monitor window. The red dot at the left of the image below shows the location of the send text box.
Click the Send button at the right of the serial monitor window. The red dot at the right of the above image shows the location of the Send button. As a result, the letter H is sent from the serial monitor window and received by the PhysicalPixel sketch running on the Arduino board. The PhysicalPixel sketch switches the on-board LED on when it receives the capital letter H.
Type a capital L into the send text box of the serial monitor window and click the Send button. The on-board LED switches off after the PhysicalPixel sketch receives the L character.
This part of the Arduino tutorial for beginners is a very simple demonstration of the serial monitor for beginners. The intent was to show what the serial monitor is. In addition it shows how an Arduino sends text to the serial monitor window. It also shows how text is sent to an Arduino from the serial monitor window.
Example sketches used in early parts of this tutorial are explained later in this tutorial. This is done so that beginners are not overwhelmed with too much information at the start of the tutorial.
As an Amazon Associate I earn from qualifying purchases:
As an Amazon Associate I earn from qualifying purchases: