Serial Monitor

Let’s introduce an important resource called the serial monitor! We are going to show you a few characteristics we’ll use as resource in other experiments.

!Important Informations

The serial monitor is the link between the computer and your Arduino. With it you can send and receive information under the form of text, which is useful for debugging and also for controlling the Arduino over the computer’s keyboard.

In order to access the serial monitor correctly, you first need to connect the board, upload your code and then click on the magnification lens symbol, which is located on the upper right-hand corner of the Arduino IDE.


!Identifying the Components

Interface Button

!Code Components

Let’s introduce the necessary functions in order to use the serial monitor:

Serial.begin: Serial.begin([baud_rate])

To make it possible to use the serial monitor, we shall first start the serial communication. That is done only once inside the setup() function.

The Serial.begin() function needs a parameter related to the transmission rate, called the baud rate. For our experiments, we are going to use the rate of 9600, however, this rate is not fixed and can vary as needed. There are a lot of values, among which the most common are 300, 2400, 4800, 9600, 19200, 57600 and 115200.

Serial.println: Serial.println([variable])

Now, in order to print the values onto the serial monitor, we must use the Serial.println() function. This function prints the value of a variable and then adds a new line. This resource is very useful because, when using it along with screen auto-scroll, what is printed on the screen is not messy.

On the code below, when the button is not pressed, the number 1 is shown, and when the button is pressed, the number 0 is shown.

!Running on Arduino

Running the code on Arduino, you can monitor if a button was pressed. As usual, on the code below you can check the comments in order to better understand how it works.

int pushButton = A0;

void setup() 
  // Initialises the serial communication with 9600 bits per second:
  pinMode(pushButton, INPUT);

void loop() 
  int buttonState = digitalRead(pushButton);
  delay(1);        // delay between readings for stability

!Your Turn!

Try modifying the reading speed of the serial monitor. Did something weird happen? Think about the reason this happens.


Transmission rates correspond to the speed at which the data is sent and are like languages of serial communication. If two devices are not speaking the same language, that is, they are not at the same speed, the data won’t be correctly interpreted. In this case, a receiver device will only receive “garbage" and because of that it is always important to check if the transmission rates are the same between two systems that are communication with each other (in this case, the computer and the Base Boarduino).