Reading Analogue Value - Potentiometer

Design Overview

The Arduino UNO in this circuit has the following pin connections and purposes:

  • GND: Connected to leg1 of the Trimmer Potentiometer, providing a ground reference.
  • 5V: Connected to leg2 of the Trimmer Potentiometer, supplying a 5V power source.
  • A0: Connected to the wiper of the Trimmer Potentiometer, used to read the variable voltage from the potentiometer.

These connections allow the Arduino UNO to read the analog voltage from the potentiometer, which can be used for various applications such as adjusting input values or controlling other components.

 

Code (Tested with Arduino Uno)

 

const int TrimmerPot = A0; // Arduino Pin A0 (Analogue) = Potentiometer

int TrimmerPotValue;

void setup() {

  Serial.begin(9600); //TX-RX serial communication with Arduino (9600 baudrate)

}

 

void loop() {

 

  TrimmerPotValue = analogRead(TrimmerPot); // Read analgue value from trim potentiometer

  

  // Convert the reading (which goes from 0 - 1023) to a voltage (0 - 5V):

  float voltage = TrimmerPotValue * (5.0 / 1023.0);

  

  // Print out the value in volts

  Serial.print("Voltage Value: ");

  Serial.print(voltage);

  Serial.println(" V");

  

  // Delay 

  delay(500);

}