27. Simple voltmeter using ADC

Back To All Submissions
Previous Submission
Next Submission

Solving Approach:

How do you plan to solve it?

Connect one terminal of Potentiometer to VCC. Connect other terminal to GND and connect the common point to analog GPIO pin (A0). 

Initialize pot pin as input and read the ADC value obtaining at A0

Find voltage by using (value*5/1024) and print it. (As Arduino have 10 bit ADC and 5 V reference voltage is selected).

Code

int pot = A0;

void setup() {
  // put your setup code here, to run once:
  pinMode(pot, INPUT);
  Serial.begin(115200);
}

void loop() {
  // put your main code here, to run repeatedly:
  float value = analogRead(pot);
  float voltage = value*5/1024; //5 V as reference voltage and Arduino have 10 bit ADC.
  Serial.println("Digital Value = " + String(value) + " | Voltage = " + String(voltage));
  delay(500);
  
}


 

Output

Video

Add video of output (know more)

 

 

 

 

 

Photo of Output

Add a photo of your hardware showing the output.

 

 

 

 

 

Was this helpful?
Upvote
Downvote