Serial Monitor | Arduino Tutorial - Arduino Getting Started

  • TUTORIALS
  • HARDWARE & TOOLS
  • REFERENCES
  • FAQs
  • ABOUT US
Home Tutorials

SENSORS/ACTUATORS

  • Arduino - Software Installization
  • Arduino - Hardware Preparation
  • Arduino - Hello World
  • Arduino - Code Structure
  • Arduino - Serial Monitor
  • Arduino - Serial Plotter
  • Arduino - LED - Blink
  • Arduino - LED - Blink Without Delay
  • Arduino - Blink multiple LED
  • Arduino - LED - Fade
  • Arduino - RGB LED
  • Arduino - Traffic Light
  • Arduino - Button
  • Arduino - Button - Debounce
  • Arduino - Button - Long Press Short Press
  • Arduino multiple Button
  • Arduino - Switch
  • Arduino - Limit Switch
  • Arduino - DIP Switch
  • Arduino - Button - LED
  • Arduino - Button - Relay
  • Arduino - Button Toggle LED
  • Arduino - Button Toggle Relay
  • Arduino - Button - Piezo Buzzer
  • Arduino - Button - Servo Motor
  • Arduino - Potentiometer
  • Arduino - Potentiometer fade LED
  • Arduino - Potentiometer Triggers LED
  • Arduino - Potentiometer Triggers Relay
  • Arduino - Potentiometer Triggers Piezo Buzzer
  • Arduino - Potentiometer Triggers Servo Motor
  • Arduino - Rotary Encoder
  • Arduino - Rotary Encoder LED
  • Arduino - Rotary Encoder - Servo Motor
  • Arduino - Piezo Buzzer
  • Arduino - Buzzer
  • Arduino - Motor
  • Arduino - DC Motor
  • Arduino - DC Motor - Limit Switch
  • Arduino - Servo Motor
  • Arduino - MG996R
  • Arduino - Servo Motor controlled by Potentiometer
  • Arduino - Light Sensor
  • Arduino - LDR Module
  • Arduino - Light Sensor Triggers LED
  • Arduino - Light Sensor Triggers Relay
  • Arduino - Light Sensor Triggers Servo Motor
  • Arduino - Ultrasonic Sensor
  • Arduino - Ultrasonic Sensor - LED
  • Arduino - Ultrasonic Sensor - Relay
  • Arduino - Ultrasonic Sensor - Piezo Buzzer
  • Arduino - Ultrasonic Sensor - Servo Motor
  • Arduino - Ultrasonic Sensor - LCD
  • Arduino - Ultrasonic Sensor - OLED
  • Arduino - Motion Sensor
  • Arduino - Motion Sensor - LED
  • Arduino - Motion Sensor - Relay
  • Arduino - Motion Sensor - Piezo Buzzer
  • Arduino - Motion Sensor - Servo Motor
  • Arduino - Motion Sensor - MP3 Player
  • Arduino - Motion Sensor - LED Strip
  • Arduino - Relay
  • Arduino - Relay Shield
  • Arduino - 2-Channel Relay Module
  • Arduino - 4-Channel Relay Module
  • Arduino - Controls Fan
  • Arduino - Controls Heating Element
  • Arduino - Car
  • Arduino - Actuator
  • Arduino - Actuator with Feedback
  • Arduino - Joystick
  • Arduino - Joystick - Servo Motor
  • Arduino - Soil Moisture Sensor
  • Arduino - Soil Moisture Sensor Pump
  • Arduino - Automatic Irrigation System
  • Arduino - LCD
  • Arduino - LCD I2C
  • Arduino - LCD 20x4
  • Arduino - LCD Keypad Shield
  • Arduino - OLED
  • Arduino - TFT LCD Display
  • Arduino - TFT LCD Touch Screen Display
  • Arduino - Round Circular TFT LCD Display
  • Arduino - Button Count - OLED
  • Arduino - Button Count - LCD
  • Arduino - 74HC595 4-Digit 7-Segment Display
  • Arduino - TM1637 4-Digit 7-Segment Display
  • Arduino - LED Matrix
  • Arduino - Bluetooth LED Matrix
  • Arduino - LED Matrix via Web
  • Arduino - Keypad
  • Arduino - Keypad 1x4
  • Arduino - Keypad - LCD
  • Arduino - Keypad - Beep
  • Arduino - Keypad - Buzzer
  • Arduino - Keypad - Relay
  • Arduino - Keypad - Servo Motor
  • Arduino - Keypad - Solenoid Lock
  • Arduino - Keypad - Electromagnetic Lock
  • Arduino - Temperature Sensor
  • Arduino - Temperature Sensor - LCD
  • Arduino - Temperature Sensor - OLED
  • Arduino - Temperature Sensor - LED Matrix
  • Arduino - Temperature via Web
  • Arduino - Temperature Sensor - Servo Motor
  • Arduino - Temperature Sensor - Relay
  • Arduino - DHT11
  • Arduino - DHT22
  • Arduino - Temperature Humidity Sensor
  • Arduino - Temperature Humidity Sensor - LCD
  • Arduino - Temperature Humidity Sensor - OLED Display
  • Arduino - LM35 Temperature Sensor
  • Arduino - TMP36 Temperature Sensor
  • Arduino - Display Temperature from LM35 Sensor on OLED
  • Arduino - Display Temperature from LM35 Sensor on LCD
  • Arduino - Control Temperature
  • Arduino - Cooling System using DHT Sensor
  • Arduino - Cooling System using DS18B20 Temperature Sensor
  • Arduino - Heating System
  • Arduino - DHT11 - Relay
  • Arduino - DHT11 - OLED
  • Arduino - DHT11 - LCD
  • Arduino - DHT22 - Relay
  • Arduino - DHT22 - OLED
  • Arduino - DHT22 - LCD
  • Arduino - Touch Sensor
  • Arduino - Touch Sensor - LED
  • Arduino - Touch Sensor - Relay
  • Arduino - Touch Sensor Toggle LED
  • Arduino - Touch Sensor Toggle Relay
  • Arduino - Touch Sensor - Piezo Buzzer
  • Arduino - Touch Sensor - Servo Motor
  • Arduino - Touch Sensor - Solenoid Lock
  • Arduino - Door Sensor
  • Arduino - Door Sensor - LED
  • Arduino - Door Sensor - Relay
  • Arduino - Door Sensor Toggle LED
  • Arduino - Door Sensor Toggle Relay
  • Arduino - Door Sensor - Piezo Buzzer
  • Arduino - Door Sensor - Servo Motor
  • Arduino - Solenoid Lock
  • Arduino - Electromagnetic Lock
  • Arduino - Button Controls Electromagnetic Lock
  • Arduino - Keypad Door Lock
  • Arduino - Door Lock System using Password
  • Arduino - Controls Door Lock via Web
  • Arduino - RFID/NFC
  • Arduino - RFID/NFC - Relay
  • Arduino - RFID/NFC - Servo Motor
  • Arduino - RFID - Solenoid Lock
  • Arduino - RFID - Electromagnetic Lock
  • Arduino - RFID/NFC Door Lock System
  • Arduino - RTC
  • Arduino - DS1307 RTC Module
  • Arduino - OLED Clock
  • Arduino - LCD Clock
  • Arduino - 7-segment Clock
  • Arduino - Water Sensor
  • Arduino - Water Leak Detector
  • Arduino - Water Sensor Relay
  • Arduino - Water Sensor Pump
  • Arduino - Water/Liquid Valve
  • Arduino - Controls Pump
  • Arduino - Button - Pump
  • Arduino - Rain Sensor
  • Arduino - Rain Sensor - LED
  • Arduino - Rain Sensor - Relay
  • Arduino - Rain Sensor - Buzzer
  • Arduino - Rain Sensor - Servo Motor
  • Arduino - Measure Voltage
  • Arduino - Sound Sensor
  • Arduino - Sound Sensor - LED
  • Arduino - Sound Sensor - Relay
  • Arduino - Sound Sensor - Servo Motor
  • Arduino - Force Sensor
  • Arduino - Flame Sensor
  • Arduino Fire Alarm
  • Arduino - Gas Sensor
  • Arduino - Gas Sensor - Relay
  • Arduino - Infrared Obstacle Avoidance Sensor
  • Arduino - Stepper Motor
  • Arduino - Controls 28BYJ-48 Stepper Motor using ULN2003 Driver
  • Arduino - Controls Stepper Motor using L298N Driver
  • Arduino - DRV8825 Stepper Motor Driver
  • Arduino - Stepper Motor and Limit Switch
  • Arduino - GPS
  • Arduino - LED Strip
  • Arduino - NeoPixel LED Strip
  • Arduino - WS2812B LED Strip
  • Arduino - Dotstar Led Strip
  • Arduino - Micro SD Card
  • Arduino - Write Variable to SD Card
  • Arduino - Log Data with Timestamp to SD Card
  • Arduino - Read Config from SD Card
  • Arduino - Audio
  • Arduino - MP3 Player
  • Arduino - RFID MP3 Player
  • Arduino - Siren
  • Arduino - SoftwareSerial
  • Arduino RS232
  • Arduino RS485
  • Arduino RS422
  • Arduino Serial to WiFi Converter
  • Arduino RS232 to WiFi
  • Arduino RS485 to WiFi
  • Arduino RS422 to WiFi
  • Arduino - IR Remote Control
  • Arduino - Bluetooth
  • Arduino - BLE
  • Arduino controls Servo Motor via Bluetooth
  • Arduino controls LED via Bluetooth
  • How to get started with Arduino Uno R4
  • Arduino Uno R4 WiFi controls LED via Web
  • Arduino Uno R4 WiFi controls Relay via Web
  • Arduino Uno R4 LED Matrix displays Number Character

INTERNET OF THING (IoT)

  • Arduino - Ethernet
  • Arduino - Ethernet Module
  • Arduino - Ethernet Shield 2
  • Arduino - PHPoC Shield
  • Arduino - WiFi
  • Arduino - TCP Client
  • Arduino - Web Server
  • Arduino - Web Server Multiple Pages
  • Arduino - Web Server Password
  • Arduino - WebSocket
  • Arduino - Web Plotter
  • Arduino - Controls Servo Motor via Web
  • Arduino - Controls Car via Web
  • Arduino - IoT
  • Arduino - MQTT
  • Arduino Shield
  • Arduino - HTTP Request
  • Arduino - HTTPS Request
  • Arduino - MySQL
  • Arduino - Modbus
  • Communication between two Arduino
  • Arduino to Arduino MQTT Communication
  • Arduino - IFTTT
  • Arduino - Make Voice Phone Call
  • Arduino - Send SMS Message
  • Arduino - Gmail
  • Arduino - Door Open Email Notification
  • Arduino - Motion Sensor Email Notification
  • Arduino - Water Leak Email Notification
  • Arduino - Secure Your Belongings: Detect Theft and Send Email Alerts
  • Arduino - Send Email
  • Arduino - Door Open - Send Email Notification
  • Arduino - Temperature - Send Email Notification

LIBRARIES

  • Arduino - Button Library
  • Example - 01.Single Button
  • Example - 02.Single Button Events
  • Example - 03.Single Button Debounce
  • Example - 04.Single Button All
  • Example - 05.Multiple Button All
  • Example - 06.Button Count
  • Example - 07.Button Array
  • Arduino - LED Library
  • Example - LED Blink
  • Example - LED Blink In Period
  • Example - LED Blink Number Of Times
  • Example - LED Fade In Fade Out
  • Example - LED On Off
  • Example - LED Toggle
  • Example - Multiple LED
  • Example - LED Array
  • Arduino - Output Library
  • Example - 01.On Off
  • Example - 02.Toggle
  • Example - 03.Single Blink Without Delay
  • Example - 04.Single Blink Change Frequency
  • Example - 05.Multiple Blink Without Delay
  • Example - 06.Multiple Blink With Offset
  • Example - 07.Blink In Period
  • Example - 08.Pulse
  • Arduino - Buzzer Library
  • Example - Beep
  • Example - Melody
  • Example - Melody Repeat
  • Arduino - Analog Keypad Library
  • Example - Analog Keypad
  • Example - Analog Button Array
Arduino - Serial Monitor

Hardware Required

1×Official Arduino Uno
1×Alternatively, DIYables STEM V3, Fully Compatible with Arduino Uno R3
1×USB 2.0 cable type A/B (for USB-A PC)
1×USB 2.0 cable type C/B (for USB-C PC)
1×Recommended: Screw Terminal Block Shield for Arduino Uno
1×Recommended: Breadboard Shield for Arduino Uno
1×Recommended: Enclosure for Arduino Uno
1×Recommended: Prototyping Base Plate & Breadboard Kit for Arduino UNO

Or you can buy the following kits:

1×DIYables STEM V3 Starter Kit (Arduino included)
1×DIYables Sensor Kit (30 sensors/displays)
1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some links in this section are Amazon affiliate links. If you make a purchase through these links, we may earn a commission at no extra cost to you.Additionally, some links direct to products from our own brand, DIYables .

About Serial Monitor

Serial Monitor is one of the tools in Arduino IDE. It is used for two purposes:

  • Arduino → PC: Receives data from Arduino and display data on screen. This is usually used for debugging and monitoring
  • PC → Arduino: Sends data (command) from PC to Arduino.

Data is exchanged between Serial Monitor and Arduino via USB cable, which is also used to upload the code to Arduino. Therefore, To use Serial Monitor, we MUST connect Arduino and PC via this cable.

How To Use Serial Monitor

Open Serial Monitor

Click the Serial Monitor icon

Arduino IDE - How to open serial monitor

Items on Serial Monitor

  1. Output console: display data received from Arduino.
COM6 Send Autoscroll Show timestamp Clear output 9600 baud   Newline  
  1. Autoscroll checkbox: option to select between automatically scroll and not scroll.
COM6 Send Autoscroll Show timestamp Clear output 9600 baud   Newline  
  1. Show timestamp checkbox: option to show timestamp prior to data displayed on Serial Monitor.
COM6 Send Autoscroll Show timestamp Clear output 9600 baud   Newline  
  1. Clear output button: clear all text on the output console.
COM6 Send Autoscroll Show timestamp Clear output 9600 baud   Newline  
  1. Baud rate selection: select communication speed (baud rate) between Arduino and PC. This value MUST be the same as the value used in Arduino code (in Serial.begin() function).
COM6 Send Autoscroll Show timestamp Clear output 9600 baud   Newline  

※ NOTE THAT:

When we select baud rate (even the value is not changed), Arduino is reset. Therefore, this is one way to reset Arduino.

  1. Textbox: user can type characters to send to Arduino
COM6 Send Autoscroll Show timestamp Clear output 9600 baud   Newline  
  1. Ending selection: select the ending characters appended to data sent to Arduino. Selection includes:
    • No line ending: append nothing
    • Newline: append newline (LF, or '\n') character
    • Carriage return: append carriage return (CR, or '\r') character
    • Both NL and CR: append both newline and carriage return (CRLF, or '\r\n') characters
    COM6 Send Autoscroll Show timestamp Clear output 9600 baud   Newline  
    1. Send button: when the button is pressed, Serial Monitor sends data in textbox plus the ending characters to Arduino
    COM6 Send Autoscroll Show timestamp Clear output 9600 baud   Newline  

Arduino To PC

To send data from Arduino to PC, we need to use the following Arduino code:

  • Set baud rate and begin Serial port by using Serial.begin() function
Serial.begin(baudrate);
  • Send data to Serial Monitor using one of the following functions: Serial.print(), Serial.println(), Serial.write(). For example, send “Hello World!” to Serial Monitor
Serial.println("Hello World!");

Example Use

In this example, we will send the “ArduinoGetStarted.com” from Arduino to Serial Monitor every second

/* * Created by ArduinoGetStarted.com * * This example code is in the public domain * * Tutorial page: https://arduinogetstarted.com/tutorials/arduino-serial-monitor */ void setup() { Serial.begin(9600); } void loop() { Serial.println("ArduinoGetStarted.com"); delay(1000); }

Quick Steps

  • Copy the above code and open with Arduino IDE
  • Click Upload button on Arduino IDE to upload code to Arduino
  • Open Serial Monitor
  • Select baurate 9600
  • See the output on Serial Monitor
COM6 Send ArduinoGetStarted.com ArduinoGetStarted.com ArduinoGetStarted.com ArduinoGetStarted.com Autoscroll Show timestamp Clear output 9600 baud   Newline  
  • Try changing Serial.println() function to Serial.print() function

PC To Arduino

How to send data from PC to Aduino and read it on Arduino

You will type text on Serial Monitor and then click Send button.

Arduino reads data and process it. To read data, we need to use the following Arduino code:

  • Set baud rate and begin Serial port
Serial.begin(baudrate);
  • Check whether data is available or not
if(Serial.available()) { // TODO }
  • Read data from Serial port using one of the following functions: Serial.read(), Serial.readBytes(), Serial.readBytesUntil(), Serial.readString(), Serial.readStringUntil(). For example:
String data = Serial.readStringUntil("\r\n");

Example Use

In this example, we will send the commands from Serial Monitor to Arduino to turn on/off a built-in LED. The commands include:

  • “ON”: turn on LED
  • “OFF”: turn off LED
How Arduino can receive a complete command? For example, when we send “OFF” command, how Arduino can know the command is “O”, “OF” or “OFF”?

⇒ When sending a command, we will append a newline character ('\n') by selecting “newline” option on Serial Monitor. Arduino will read data until it meets the newline character. In this case, the newline character is called delimiter.

/* * Created by ArduinoGetStarted.com * * This example code is in the public domain * * Tutorial page: https://arduinogetstarted.com/tutorials/arduino-serial-monitor */ void setup() { Serial.begin(9600); pinMode(LED_BUILTIN, OUTPUT); // set the digital pin as output: } void loop() { if(Serial.available()) // if there is data comming { String command = Serial.readStringUntil('\n'); // read string until meet newline character if(command == "ON") { digitalWrite(LED_BUILTIN, HIGH); // turn on LED Serial.println("LED is turned ON"); // send action to Serial Monitor } else if(command == "OFF") { digitalWrite(LED_BUILTIN, LOW); // turn off LED Serial.println("LED is turned OFF"); // send action to Serial Monitor } } }

Quick Steps

  • Copy the above code and open with Arduino IDE
  • Click Upload button on Arduino IDE to upload code to Arduino
  • Open Serial Monitor
  • Select baurate 9600 and newline option
  • Type “ON” or “OFF” and click Send button
COM6 Send Autoscroll Show timestamp Clear output 9600 baud   Newline  
  • See the built-in LED's state on Arduino board. We will see LED's state is ON or OFF, respectively.
  • We also see LED's state on Serial Monitor
COM6 Send LED is turned ON Autoscroll Show timestamp Clear output 9600 baud   Newline  
  • Try typing “ON” or “OFF” command some times.

Video Tutorial

We are considering to make the video tutorials. If you think the video tutorials are essential, please subscribe to our YouTube channel to give us motivation for making the videos.

Function References

  • Serial.available()
  • Serial.begin()
  • Serial.print()
  • Serial.println()
  • Serial.read()
  • Serial.readBytes()
  • Serial.readBytesUntil()
  • Serial.readString()
  • Serial.readStringUntil()
  • Serial.write()

The Best Arduino Starter Kit

  • See the best Arduino kit for beginner

See Also

  • Arduino - Software Installization
  • Arduino - Hardware Preparation
  • Arduino - Hello World
  • Arduino - Code Structure
  • Arduino - Serial Plotter

※ OUR MESSAGES

  • We are AVAILABLE for HIRE. See how to hire us to build your project
  • If this tutorial is useful for you, please give us motivation to make more tutorials.
  • You can share the link of this tutorial anywhere. Howerver, please do not copy the content to share on other websites. We took a lot of time and effort to create the content of this tutorial, please respect our work!
PREVIOUS NEXT DISCLOSURE ArduinoGetStarted.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com, Amazon.it, Amazon.fr, Amazon.co.uk, Amazon.ca, Amazon.de, Amazon.es, Amazon.nl, Amazon.pl and Amazon.se Copyright © 2018 - 2025 ArduinoGetStarted.com. All rights reserved. Terms and Conditions | Privacy Policy Email: [email protected]

TABLE OF CONTENTS

  • Hardware Required
  • About Serial Monitor
  • How To Use Serial Monitor
  • Arduino To PC
  • PC To Arduino
  • Video
  • Function References
  • The Best Arduino Starter Kit
  • See Also
×

Tag » Arduino Rs232 Example