Precision voltmeter using ADC

Solving Approach:

How do you plan to solve it?

 

 

Code

/*Paste your code here*/
#define potpin A0
uint8_t current_analogReference;
float voltageval;
int potval;
void setup()
{
  Serial.begin(9600);
  analogReference(INTERNAL);
  current_analogReference = INTERNAL;
}

void loop()
{
  if(potval == 1023 && current_analogReference == INTERNAL){
    analogReference(DEFAULT);
    current_analogReference = DEFAULT;
  }
  if(potval < 225 && current_analogReference == DEFAULT){
    analogReference(INTERNAL);
    current_analogReference = INTERNAL;
  }
  potval = analogRead(potpin);
  if(current_analogReference == DEFAULT)
  	voltageval = (float) potval / 1023 * 5.0;
  else 
    voltageval = (float) potval / 1023 * 1.1;
  Serial.print("ADC Value: ");
  Serial.print(potval);
  Serial.print(" | Voltage: ");
  Serial.println(voltageval, 3);
  delay(500);
}


 

Output

Video

Add video of output (know more)

 

 

 

 

 

Photo of Output

Add a photo of your hardware showing the output.

 

 

 

 

Upvote
Downvote

Submit Your Solution

Note: Once submitted, your solution goes public, helping others learn from your approach!