Beginner15 min50 XP base

Serial Monitor Basics

Print sensor readings and debug your sketches in real time over USB with the Serial Monitor.

1What is Serial Communication?

Serial communication lets your Arduino send and receive text data over the USB cable that connects it to your computer. This is your primary debugging tool — when something isn't working, print values to the Serial Monitor to see exactly what your code is doing.

Data is transmitted as a series of bits, one at a time, at a defined speed called the baud rate (bits per second). Both the Arduino and the Serial Monitor must use the same baud rate or you'll see garbage characters.

2Serial.begin() and Baud Rate

You initialize serial communication in setup() with Serial.begin(baudRate). The most common baud rate is 9600. Higher rates (115200) transfer faster but are less reliable over long distances.

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

Note: Open the Serial Monitor in the Arduino IDE with Ctrl+Shift+M (or Tools → Serial Monitor). Make sure the baud rate dropdown at the bottom matches your Serial.begin() value.

3print() vs println()

Serial.print() sends data without a newline at the end — the next print continues on the same line. Serial.println() adds a newline character, moving the cursor to the next line.

void loop() {
  int sensorValue = analogRead(A0);

  Serial.print("Sensor: ");     // No newline
  Serial.println(sensorValue);  // Newline after value

  delay(500);
}

You can print any data type: integers, floats, strings, characters. Serial.print(3.14) prints 3.14. Serial.print('A') prints A.

4Reading Sensor Values

analogRead(pin) reads an analog pin (A0–A5) and returns a value from 0 to 1023, representing 0V to 5V. This is perfect for reading potentiometers, light sensors, and temperature sensors.

void setup() {
  Serial.begin(9600);
}

void loop() {
  int raw = analogRead(A0);           // 0–1023
  float voltage = raw * (5.0 / 1023.0);  // Convert to volts

  Serial.print("Raw: ");
  Serial.print(raw);
  Serial.print(" | Voltage: ");
  Serial.print(voltage);
  Serial.println("V");

  delay(200);
}

5Serial.available() — Reading Input

You can also send data FROM your computer TO the Arduino. Serial.available() returns the number of bytes waiting to be read. Serial.read() reads one byte.

void loop() {
  if (Serial.available() > 0) {
    char incoming = Serial.read();
    Serial.print("You sent: ");
    Serial.println(incoming);

    if (incoming == '1') {
      digitalWrite(13, HIGH);
    } else if (incoming == '0') {
      digitalWrite(13, LOW);
    }
  }
}

Skill Check

8 questions · Up to 180 XP

Q1.What does Serial.begin(9600) do?

Q2.What is the difference between Serial.print() and Serial.println()?

Q3.What range does analogRead() return?

Q4.What happens if the Serial Monitor baud rate doesn't match Serial.begin()?

Q5.What does Serial.available() return?

Q6.Which pins are analog inputs on the Arduino Uno?

Q7.What does Serial.read() return when the buffer is empty?

Q8.What is baud rate?

Sign in to earn XP for your answers.