Most microcontrollers today have built-in analog to digital converters (ADC) .
Analog signals: Directly measurable quantities in terms of some other quantity
                       Some examples: 
                       Thermometer: The mercury liquid inside the thermometer rises as temperature rises 
                       Car Speedometer: Needle of a car speedometer moves farther right as you accelerate 
                       Audio Amplifier: The volume of an audio amplifier increases as you turn the knob. 
Digital Signals: Have only two states. or 1on or off. 
                       Example: A switch can be either on or off.

Figure 1: Arduino Uno Analog inputs

Not all pins of the Arduino board can be used as analog inputs, the numbers of these pins depend on the Arduino model you are using, the Arduino Uno has 6 analog inputs labelled A0, A1, A2, A3, A4 and A5 as shown on figure 1 above. 

These analog to digital converters allow analog continuous voltages to be converted into a discreet 10-bit digital numbers inside the microcontroller as the microcontroller can only process digital numbers. This basically mean the analog pins have the ability to detect 1,024 (210) discrete analog levels compared to two levels only (0 and 5V) of the digital pins. This can enable the Arduino to be connected to analog sensors such as temperature sensors, pressure sensors, humidity sensors, optical sensors, and power sensors. 

Any sensor which can generate a voltage between 0V and a maximum 5V can be used. If the output voltage is higher than 5V, a method to step it down should be used such as a voltage divider with resistors.  Figure 2 below shows a potentiometer wiper pin connected to A0 pin of the Arduino. By varying this potentiometer, the voltage across will change as well and displayed on the LCD.

Figure 2: A potentiometer and LCD on breadboard connected to Arduino Uno

                                         Arduino Analog Functions
Description: This function configures the reference voltage used for analog input (i.e. the value used as the top of the input range). The options are:

  • DEFAULT: the default analog reference of 5 volts (on 5V Arduino boards) or 3.3 volts (on 3.3V Arduino boards)
  • INTERNAL: an built-in reference, equal to 1.1 volts on the ATmega168 or ATmega328 and 2.56 volts on the ATmega8 (not available on the Arduino Mega)
  • INTERNAL1V1: a built-in 1.1V reference (Arduino Mega only)
  • INTERNAL2V56: a built-in 2.56V reference (Arduino Mega only)
  • EXTERNAL: the voltage applied to the AREF pin (between 0 to 5V only any other voltage may damage your board) is used as the reference.


analogReference(type) //type: which type of reference to use (DEFAULT, INTERNAL, INTERNAL1V1, INTERNAL2V56, or EXTERNAL).


Description: This function reads the value from the specified analog pin. The Arduino board contains a 6 channel (8 channels on the Mini and Nano, 16 on the Mega), 10-bit analog to digital converter. This means that it will map input voltages between 0 and 5 volts into integer values between 0 and 1023. This yields a resolution between readings of: 5 volts / 1024 units or, .0049 volts (4.9 mV) per unit. The input range and resolution can be changed using analogReference(). It takes about 100 microseconds (0.0001 s) to read an analog input, so the maximum reading rate is about 10,000 times a second. This function will return a int value between 0 and 1023. If the analog input pin is not connected to anything, the value returned by analogRead() will fluctuate based on a number of factors (e.g. the values of the other analog inputs, how close your hand is to the board, etc.).

analogRead(pin) // pin is the Arduino pin selected.

Arduino ADC Example

Figure 3 below shows a potentiometer wiper pin connected to A0 pin of the Arduino. By varying this potentiometer, the voltage across will change as well and displayed on the LCD.

Figure 3: potentiometer connected to A0 pin of the Arduino Uno

 This example Demonstrates the use a 16x2 LCD display and Analog sensor.  

 This sketch prints the voltage across the variable resistor

  The circuit:
 * LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * LCD R/W pin to ground
 * LCD VSS pin to ground
 * LCD VCC pin to 5V
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)

 * The Variable Resistor is connected To A0

int Vin;  // Variable to read the value from Arduino A0
float Voltage; // variable that receives the converted voltage

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("Voltage = ");

void loop() {
  Vin = analogRead(0);    //Tell the Arduino to read the voltage on pin A0
  Voltage = (5.0 * Vin)/1023; // Convert the read value into a voltage. 
  // set the cursor to column 10, line 0
  // (note: line 0 is the first row, since counting begins with 0):
  lcd.setCursor(10, 0);
   // Print the voltage 
  lcd.print("V");     // Print "V"

The potentiometer will vary the voltage from 0 to 5V, with 10 bits of resolution for Analog/Digital conversion (1024 different values to represent the voltage). Thus, the maximum value (1023: It is from 0 to 1023) will be 5V. The halfway will be 511 or 2.5V, and so forth.

In doing math with float numbers, you need to add a decimal point, otherwise it will be treated as an int. That is why we used 5.0 and not just 5.

You can download the full project files (Arduino Sketch and Proteus Schematic design) below here. All the files are zipped, you will need to unzip them (Download a free version of the Winzip utility to unzip files).

Download: Analog_sketch

Download: Arduino-Analog-Proteus