Back to Step by Step Course by Robojax

Lesson 10: Using Potentiometer reading voltage, Analog and Digital

Please select other codes for this lecture from the links below.

We first learn the difference between Analog and digital. Then we learn what is Potentiometer and how to measure DC voltage with Arduino and the how to find the value of resistor.

 * S01-10 Potentiometer
  Please watch video instruction here
 This code is available at
with over 100 lectures Free On  YouTube Watch it here
Get the code for the course: 
 * Written by Ahmad Shamshiri for Robojax,
 * Feb 23, 2019
const int potPin = A0;// pint name for reading voltage

void setup() {
  Serial.begin(9600);// initialize the serial monitor
  Serial.println("Reading Analog vlaue");


void loop() {
//Robojax Step By Step Arduino Course
  int potValue = analogRead(potPin);// read the input value 
  Serial.print(" Voltage:");
  float voltage = potValue * (5.0 / 1023.0);
  if(voltage >= 2.8 && voltage <= 4.1) 
    Serial.println("Voltage between 2.8 and 4.1");



The least I expect from you is to give the video a thumbs up and subscribe to my channel. I appreciate it. I have spent hundreds of hours making these lectures and writing code. You don't lose anything by subscribing to my channel. Your subscription is a stamp of approval for my videos, helping more people find them and, in turn, helping me. Thank you!

If you found this tutorial helpful, please support me so I can continue creating content like this. support me via PayPal

**** AFFILIATE PROGRAM **** We are a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for us to earn fees by linking to and affiliated sites.

Right Side