Home · Academy · Robotics & Coding · Arduino · The Serial Monitor

The Serial Monitor

Learn to print values to the computer with Serial and use it for debugging.

LESSON COMPASS

What will you use this page for?

Core idea

The Serial Monitor is a window that shows what is happening inside the Arduino by sending values over the USB cable to your computer screen, letting us see numbers and find mistakes.

Evidence to produce

Complete the page task with your own input, test conditions and reasoning.

Control trap

Forgetting to write Serial.begin If there is no Serial.begin(9600) inside setup() , the Serial Monitor stays empty. The print command does nothing. This is the first place to check. Baud rate mismatch If the code says 9600 but the Serial Monitor says 115200 , strange symbols appear on the screen. Making both values…

Next connection

PWM: We will learn to make an LED glow gradually instead of only fully on or fully off, and to set motor speed with analogWrite .

Module sources: Python Tutorial · Arduino Learn

LevelBeginner
Age10–16
Duration30–45 min
PrerequisiteAnalog Reading
ContentStandard lesson · 1,593 words
Last updated

One-sentence summary

The Serial Monitor is a window that shows what is happening inside the Arduino by sending values over the USB cable to your computer screen, letting us see numbers and find mistakes.

Why it matters

The Arduino has no screen of its own. When it reads a sensor or does a calculation, it cannot show us the result directly. The board "thinks" that the temperature is 512 right now, but we have no way to see it.

This is exactly where the Serial Monitor helps. The Arduino sends the values it measures over the USB cable to the computer, and we read them in a text window. Because of this we can:

In short, the Serial Monitor is the simplest way for the Arduino and us to talk. As we move on to PWM and more complex projects, it will also be our most powerful tool for finding mistakes.

How does serial communication work?

The Arduino and the computer talk over the USB cable using serial communication. The word "serial" means the data is sent one piece at a time, in order. Letters and numbers line up one after another and travel to the computer.

Starting the conversation with Serial.begin

Before we print anything, we have to open serial communication. We do this once, inside setup():

void setup() {
  Serial.begin(9600); // Start serial communication
}

void loop() {
  Serial.println("Hello world"); // Print a line
  delay(1000);                   // Wait 1 second
}

The line Serial.begin(9600) means "we will talk to the computer at a speed of 9600 signals per second." That speed value is called the baud rate.

What is baud rate?

Baud rate is the number that tells how fast the data is sent. 9600 is the most commonly used value and it is perfectly fine for a start.

There is only one rule that really matters: the baud rate in your code must match the baud rate in the Serial Monitor. If your code says 9600, the box in the bottom corner of the Serial Monitor must also say 9600. Otherwise you will see meaningless symbols on the screen.

The difference between print and println

We use two commands to print values:

Let's see it with an example:

Serial.print("Temperature: ");  // Stays on the same line
Serial.println(24);             // Writes and moves down

On the screen it looks like this:

Temperature: 24

Using print to place a label (text) and then println for the number is a very common pattern. That way the screen shows a clear line like "Light value: 512" instead of just "512".

Two everyday examples

Example 1: A doctor's notebook

When you visit a doctor, they measure your temperature and write it in a notebook: "Temp: 37.2". The thermometer measures the value, and the doctor records it in a readable form. The Serial Monitor is just like that notebook. The Arduino measures, and the Serial Monitor writes the result on screen in a readable way. Without the notebook, the doctor could not remember which value was which.

Example 2: The screen at a bus stop

The screen at a bus stop says "Bus number 12 arriving in 3 minutes." The buses are moving somewhere out of sight, but the screen keeps reporting the situation to you. The Serial Monitor reports the values running inside the Arduino to us in the same live way.

Printing a sensor value

Now let's combine the analog reading from the previous lesson with the Serial Monitor. You can use a potentiometer or a light sensor (LDR).

Wiring: One leg of the LDR goes to 5V, the other leg goes to both the A0 pin and, through a 10 kΩ resistor, to GND. This resistor forms the voltage divider we need for the measurement.

int sensorPin = A0; // The analog pin the sensor is on

void setup() {
  Serial.begin(9600); // Start serial communication
}

void loop() {
  int value = analogRead(sensorPin); // Read 0-1023
  Serial.print("Light value: ");     // Write a label
  Serial.println(value);             // Write the number, new line
  delay(500);                        // Wait half a second
}

After uploading the code, open the Serial Monitor. When you cover the sensor with your hand, you will see the number change. As the light drops, the value shifts, and that is the heart of debugging: seeing the real numbers with your own eyes.

Printing with millis instead of delay

When you write delay(500), the Arduino cannot do anything else during that half second. In small projects that is fine, but when you want to do other jobs too, this waiting becomes a problem. For non-blocking timing we use millis(). millis() gives the number of milliseconds since the board turned on:

unsigned long previousTime = 0; // The last moment we printed

void loop() {
  if (millis() - previousTime >= 500) { // Has 500 ms passed?
    previousTime = millis();            // Update the time
    int value = analogRead(A0);         // Read the sensor
    Serial.println(value);              // Print the value
  }
  // Other jobs can be added here too
}

In this structure the Arduino does not wait; it keeps checking the clock and prints when the time comes. It may look complex at first, but it will be very useful later in projects that do more than one job at the same time.

Mini activity

Improve the sensor code above with these steps:

  1. Upload the code to the board and open the Serial Monitor.
  2. Note the smallest and largest values you see when reading the sensor in a bright room and a dark one.
  3. Change the code to add this: if the value is less than 300, print Serial.println("Dark"), otherwise print Serial.println("Bright").
  4. Check in the Serial Monitor whether the label changes with the light.

This is the first piece of the automatic night light that turns on an LED in the next step.

Common mistakes

Forgetting to write Serial.begin

If there is no Serial.begin(9600) inside setup(), the Serial Monitor stays empty. The print command does nothing. This is the first place to check.

Baud rate mismatch

If the code says 9600 but the Serial Monitor says 115200, strange symbols appear on the screen. Making both values the same solves the problem.

Mixing up print and println

If you keep using Serial.print(), everything sticks together on one line. For readable lines, remember to use println at the end.

Setting the delay too small

If you write delay(1), the screen scrolls so fast that you cannot read anything. To read values comfortably, something between delay(300) and delay(1000) is a good start.

Safety note

Lesson summary

Check questions

  1. What does the Serial.begin(9600) line do, and where in the code is it written?
  2. What is the difference between Serial.print and Serial.println?
  3. What is baud rate, and why must it be the same in the code and in the Serial Monitor?
  4. If the screen is empty when you open the Serial Monitor, what are the first two things you would check?
  5. What is the advantage of using millis() instead of delay(500)?

Answers

  1. It starts serial communication, which opens the Arduino's talk with the computer over USB. It is written once, inside setup().
  2. Serial.print stays on the same line after writing; Serial.println moves to the next line. For a label + number you usually use print first, then println.
  3. Baud rate is the speed at which data is sent (for example 9600). If the code and the Serial Monitor do not use the same speed, meaningless symbols appear because the two sides decode each other incorrectly.
  4. First check whether Serial.begin is in setup(); then check whether the baud rate value in the Serial Monitor matches the one in the code.
  5. millis() does not pause the Arduino; the board can do other jobs at the same time. delay stops everything for that whole period.

Source and verification note

For “The Serial Monitor”, verification focuses on whether the relationship between How does serial communication work? and What is baud rate? remains consistent across examples. Pin, voltage and current limits can differ between Arduino-compatible boards. Compiling code does not guarantee a safe circuit; loads such as motors and servos require a suitable driver and external power where appropriate.

Next lesson

PWM: We will learn to make an LED glow gradually instead of only fully on or fully off, and to set motor speed with analogWrite.

Start QuizBack to Arduino
QUESTION POOL

Reinforce this lesson with 10 questions

This lesson has a pool of 20 questions. Each attempt selects 10 and reshuffles the choices.