Project 1: Read an Analog Value (AnalogReadSerial)

Created on: 2 August 2012
Updated on: 16 January 2023

Tutorial 10 – Pages

How to read an analog value from one of the Arduino Uno analog pins. An analog value is continuously read from one of the analog input pins of the Arduino board. The analog value that is read is continuously sent out of the Arduino Uno USB serial port and displayed in the Arduino IDE serial monitor window. A potentiometer is used to change the analog value.

Parts Needed

Besides an Arduino Uno or compatible board, USB cable, breadboard and wire links, you will need:

1 × 10k panel-mount potentiometer or 10k preset potentiometer.

Male to female Dupont wires can be used to connect a straight pinned potentiometer directly to an Arduino Uno – read the rest of this article for details.

If you don't have a potentiometer, you can still load the program and measure analog values from the 5V, 3.3V and GND pins of the Arduino using a wire link.

Project 1 Video: How to Read an Arduino Analog Pin Value

The following video shows what you will achieve in this part of the tutorial. The video shows Arduino IDE version 1.x, but the data from the Arduino looks the same in the version 2.x Arduino IDE.

In the video, the analog value read from an Arduino Uno analog pin is continually updated in the Arduino IDE Serial Monitor window. As the preset potentiometer is turned, so the value in the Serial Monitor window changes.

Arduino Website Page

The AnalogReadSerial page on the Arduino website has more information and a circuit diagram for this project.

In the Arduino IDE

Open the sketch for this project from the built-in examples in the Arduino IDE, select File → Examples → 1.Basics → AnalogReadSerial from the top Arduino IDE menu.

Build the Circuit to Read an Arduino Uno Analog Pin Value

Connect either a panel-mount potentiometer, or a preset potentiometer, to the Arduino Uno as shown on the Arduino website page for this project.

If you are using a preset potentiometer, then it is easier to use a breadboard to connect the potentiometer to the Arduino board. A panel-mount potentiometer will usually have either straight pins, or terminals with loops. A potentiometer with straight pins can either be plugged directly into a breadboard, or Dupont wires with a socket on one end and pin on the other (male to female Dupont wire) can be attached to the potentiometer. A potentiometer that has terminals with loops will need to have wires soldered to it. A potentiometer with wires attached can usually be connected directly to the Arduino board.

Connect the Potentiometer to the Arduino Uno

Connect the middle pin or wiper of the potentiometer to the A0 analog Arduino pin. Connect one of the outer pins of the potentiometer to a GND pin of the Arduino. Connect the other outer pin to the 5V pin of the Arduino.

The photo below shows a preset potentiometer connected to the Arduino.

A Potentiometer Connected to an Arduino Uno to Read an Analog Value
A Potentiometer Connected to an Arduino Uno to Read an Analog Value

Programming and Operating the Circuit

Start the Arduino IDE and select File → Examples → 1.Basics → AnalogReadSerial to open the Arduino code (sketch) for the project. Verify and then upload the sketch. Now open the serial monitor window from the Arduino IDE.

The serial monitor displays the value that is being read from the A0 analog pin of the Arduino. Turn the shaft of the potentiometer to see the value change. Use a screwdriver to adjust the potentiometer if using a preset potentiometer.

When the potentiometer shaft is turned all the way to the pin that is connected to GND, the value displayed in the serial monitor will be 0. When turned all the way to the pin that is connected to 5V, the value will be 1023.

If you do not have a potentiometer, then insert a single core wire into the A0 connection on the Arduino board. To see the value change in the serial monitor window, connect the other end of the wire to the 5V, 3.3V or GND connections of the Arduino.