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:
- See whether a sensor is really working.
- Check whether values fall in the range we expect.
- Understand where we went wrong when the code misbehaves.
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:
Serial.print("...")writes but does not start a new line. The next text continues on the same line.Serial.println("...")writes and then moves to the next line.
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:
- Upload the code to the board and open the Serial Monitor.
- Note the smallest and largest values you see when reading the sensor in a bright room and a dark one.
- Change the code to add this: if the value is less than 300, print
Serial.println("Dark"), otherwise printSerial.println("Bright"). - 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
- This lesson uses only low voltage: the Arduino is powered by the computer's USB port or a suitable battery pack. Mains electricity from a wall socket is never used.
- When wiring the sensor, the board's power comes from USB; it is a good habit to unplug the cable before changing the circuit.
- Always use the correct resistor with analog sensors; if you skip the resistor, too much current can reach the pins.
- When building a circuit for the first time, ask an adult to check the connections. Strong parts like motors or pumps are not part of this lesson; those need a separate power source and a motor driver.
Lesson summary
- The Serial Monitor is the window that writes the Arduino's measured values to the computer screen over USB.
- To start communication,
Serial.begin(9600)is written once insidesetup(). Serial.printstays on the same line, whileSerial.printlnmoves to the next line.- The baud rate in the code must match the baud rate in the Serial Monitor.
- Seeing values with your own eyes is the most powerful and simplest way to debug.
Check questions
- What does the
Serial.begin(9600)line do, and where in the code is it written? - What is the difference between
Serial.printandSerial.println? - What is baud rate, and why must it be the same in the code and in the Serial Monitor?
- If the screen is empty when you open the Serial Monitor, what are the first two things you would check?
- What is the advantage of using
millis()instead ofdelay(500)?
Answers
- It starts serial communication, which opens the Arduino's talk with the computer over USB. It is written once, inside
setup(). Serial.printstays on the same line after writing;Serial.printlnmoves to the next line. For a label + number you usually useprintfirst, thenprintln.- 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.
- First check whether
Serial.beginis insetup(); then check whether the baud rate value in the Serial Monitor matches the one in the code. millis()does not pause the Arduino; the board can do other jobs at the same time.delaystops 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.