Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Voltaat Arduino Ultimate Kit
40 min
Share

Measure the potentiometer values with Arduino

Rotary potentiometers are a type of variable resistance that allows you to adjust the resistance and therefore, the voltage. They are used in several applications, such as adjusting audio volume or light brightness.

Project Video

Overview

In this tutorial, we will use the Arduino to display the potentiometer values in percentage and display them on your computer.

Getting the Items

Arduino Uno R3 (Voltaat Version)
Get Item
Rotary Potentiometer
Get Item
Half-size Breadboard
Get Item
Jumper Wires - Male to Male (40 Pack)
Get Item

Steps

Wiring it Up

Connect the wires between the potentiometer and the Arduino, as shown in the image below.

 Connections from the Rotary potentiometer to the Arduino:


 • potentiometer GND pin → Arduino GND pin


 • potentiometer out pin → Arduino A0 pin


 • potentiometer VCC pin → Arduino 5V pin

Coding


/*
 Voltaat learn (http://learn.voltaat.com)
 Link for full tutorial:
 Tutorial: Measure the potentiometer values

 The function of this sketch is to read the rotary potentiometer values
 and display them in percentage on your computer

 Connections from the Rotary potentiometer to the Arduino:
 • potentiometer GND pin → Arduino GND pin
 • potentiometer out pin → Arduino A0 pin
 • potentiometer VCC pin → Arduino 5V pin
*/

//Define the variable PotentiometerRead to Analog Input Pin A0
#define PotentiometerRead A0

//Commands inside void setup run once
void setup()
{
 //Start the serial monitor at 9600 baud rate (9600 bits per second)
 Serial.begin(9600);
}

//Commands inside void loop run forever
void loop()
{
 //Read the analog value from the potentiometer out pin and assign it to the variable Read
 int Read = analogRead(PotentiometerRead);
 //Convert the value to percentage
 int percentage = map(Read, 0, 1023, 0, 100);
 //Print to serial monitor
 Serial.print("The Potentiometer at ");
 Serial.print(percentage);
 //Print "%" to the serial monitor and then add a new line
 Serial.println("%");
 //wait for 100ms
 delay(100);
}

Testing it Out

know when your plant needs watering

Now access the serial monitor on your Arduino IDE by clicking on the magnifying glass icon at the top right corner.

know when your plant needs watering

Now, as we see in the following image, the serial monitor displays the potentiometer values in percentage. You can change the resistance value by rotating it and see the new outcome right away on your computer.

know when your plant needs watering

Resources

No items found.