We're going to start plotting...values! Arduino comes with a cool tool called the Serial Plotter. It can give you visualizations of variables in real-time. This is super useful for visualizing data, troubleshooting your code, and visualizing your variables as waveforms. 

We are going to first need to modify the code for CIRC08. Copy and paste the code below into the Arduino Editor. Then compile and upload.

Download: file
  Analog Input, but with Serial Plotter!
 Demonstrates analog input by reading an analog sensor on analog pin 0 and
 turning on and off a light emitting diode(LED)  connected to digital pin 13.
 The amount of time the LED will be on and off depends on
 the value obtained by analogRead().

 The circuit:
 * Potentiometer attached to analog input 0
 * center pin of the potentiometer to the analog pin
 * one side pin (either one) to ground
 * the other side pin to +5V
 * LED anode (long leg) attached to digital output 13
 * LED cathode (short leg) attached to ground

 * Note: because most Arduinos have a built-in LED attached
 to pin 13 on the board, the LED is optional.

 Created by David Cuartielles
 modified 30 Aug 2011
 By Tom Igoe

 This example code is in the public domain.



int sensorPin = A0;    // select the input pin for the potentiometer
int ledPin = 13;      // select the pin for the LED
int sensorValue = 0;  // variable to store the value coming from the sensor

void setup() {
  // declare the ledPin as an OUTPUT:
  pinMode(ledPin, OUTPUT);
  // begin the serial monitor @ 9600 baud

void loop() {
  // read the value from the sensor:
  sensorValue = analogRead(sensorPin);

  Serial.print(" ");

When you call Serial.println(value), the Serial Plotter will put that variable on the plot. The Y-Axis of the plot auto-resizes. 

If you want to plot multiple variables, you'll need a Serial.println(value) call for each of the variables, separated by a Serial.print(" ") or Serial.print("\t"):


Serial.print(" ");


Let's try it out with the new code above. Compile and upload the program above, then navigate to Tools > Serial Plotter. The code uses a baud rate of 9600, make sure it's set in the serial monitor as 9600 too.

You should see something like this when you twist the trim potentiometer around:

This guide was first published on Aug 18, 2017. It was last updated on Aug 18, 2017.
This page (Using the Arduino Serial Plotter) was last updated on Oct 22, 2020.