Using The Arduino IDE Serial Monitor

The Arduino IDE serial monitor is an extremely useful tool for troubleshooting and fault finding in your code. If your code is giving you erratic or unexpected results then a good place to start is by displaying the key variables used in your code through the serial monitor tool in order to see where the problem arises. This tutorial is going to briefly take you through setting up and using it in your code.

This tutorial assumes that you have worked with and are familiar with the Arduino IDE and interface. If this is your first project then we recommend that you familiarise yourself with programming an Arduino first.

What You’ll Need To Use The Serial Monitor

  • Arduino (Uno Used in this Example) – Buy Here
  • USB A to B Cable – Supplied With The Above
  • A Computer

How To Set Up And Use The Serial Monitor

In order to be able to use the serial monitor function, you need to add a single line to the setup function of your code to initialise the serial communication.

void setup ()
{
Serial.begin (9600); // initialize serial communication at 9600 bps
}

Next, you’ll simply need to use a single line of code to display anything on the serial monitor.

Serial.println (variableValue);

You can also display static text to help organise what is displayed, such as:

Serial.println (“Temperature Sensor Value: ” + tempSensor);

Once you compile and run your code, you’ll need to open the serial monitor on your computer in order to be able to see the data being sent to it. It can be opened through Arduino IDE by clicking on Tools > Serial Monitor.

That is, it is a really simple and very effective tool to assist you with fault finding. Let us know if you have any queries or issues in the comments section below, we would love to help you out.

Michael Klements
Michael Klements
Hi, my name is Michael and I started this blog in 2016 to share my DIY journey with you. I love tinkering with electronics, making, fixing, and building - I'm always looking for new projects and exciting DIY ideas. If you do too, grab a cup of coffee and settle in, I'm happy to have you here.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest posts

Which NVMe Hat Is The Best For A Raspberry Pi 5

If you don’t know already, I’ve been selling these 3D printed cases for Raspberry Pi’s online for a few years now. With the launch...

Track Aircraft In Real-time With Your Raspberry Pi Using The FlightAware Pro

Have you ever seen a flight overhead and wondered where it is going? Or seen a unique-looking aircraft and wondered what type or model...

Pi 5 Desktop Case For NVMe Base or HatDrive! Bottom

Today we're going to be assembling a 3D-printed case for the Raspberry Pi 5 and Pimoroni's NVMe Base or Pineberry's HatDrive! This is an...

Related posts