Tutorial 5: Analog Inputs

An analog input differs from a digital input in that we have the ability to determine what voltage level our signal is at. With digital inputs we only get a binary input: "5V" or "0V". What happens if we want to measure something in between? That is what analog inputs are for. The Arduino Uno has built in analog to digital functionality so that we can measure voltage levels. The Uno sports six analog input pins. In this tutorial I show you how to identify and use these pins.

DIFFICULTY
EASY
CIRCUITRY KNOWLEDGE
LITTLE
C++ PROGRAMMING
LITTLE
ABOUT
0
MINUTES
  • How to identify the analog pins on an Arduino
  • How to connect to the analog pins on the Arduino Uno
  • How to build a voltage divider circuit
  • How to use the analogRead Arduino command
You can copy / paste the code below if you’re having issues with typos or want a shortcut. However I recommend that you follow along in the tutorial to understand what is going on!


int analogPin = A5 ;
int val ;

void setup() {
  Serial.begin(9600) ;
  pinMode(analogPin, INPUT) ;
}

void loop() {
  val = analogRead(analogPin) ;
  Serial.println(val) ;

  delay(1000) ;
}