All submissions

Precision voltmeter using ADC

Solving Approach:

How do you plan to solv

Change the analogReference between INTERNAL (1.1V) and DEFAULT (5V)

Use a digital pin to affect the change

Code

// using arduino t measure voltage
// two ranges: 0->1.1 and 1.1->5
// slide switch on Digital port 2 for switching range
int reference = 0;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(2, INPUT_PULLUP);
}


void loop() {
  // put your main code here, to run repeatedly:
  bool ref;
  int rawval;
  int val;

  ref = digitalRead(2);
  switch(ref) {
    case LOW:
      reference= 1100;
      analogReference(INTERNAL);
      break;

    case HIGH:
      reference= 5000;
      analogReference(DEFAULT);
      break;
  }
  
  rawval = analogRead(A0);
  Serial.print("Switch: "); Serial.print(ref); Serial.print(", ");
  Serial.print("Max: ");Serial.print(reference); Serial.print(" mV, ");
  Serial.print("Rawval:  ");Serial.print(rawval);  Serial.print(", ");
  val=map(rawval,0, 1023, 0, 1100);
  Serial.print("Measured: ");Serial.print(val); Serial.println(" mV");
  delay(500);
}

Output

Video

Add video of output (know more)

 

 

 

 

 

Photo of Output

Add a photo of your hardware showing the output.

 

 

 

 

Submit Your Solution

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