Simple voltmeter using ADC

Solving Approach:

How do you plan to solve it?

The first spte is to obtain the raw values of the adc through the function analogRead(pot);

Then calculate a new range o values to represent a proportional voltage value within 0 to 5V using values that goes from 0 to 1023;

1023 / 5v = 204.6  ----> 1023/204.6 = 5v

Code

/*Paste your code here*/
const char pot = A0;

// Las entradas a analogicas no es necesario declarar
// Iniciamos la comunicacion UART-USB a 9600 baudios o bps(solo en caso de UART)
void setup() { Serial.begin(9600);} 

void loop() {
 int adc = analogRead(pot);     // Leemos los valores del ADC que van de 0 a 1023 (10 bits de resolucion)
 float voltaje = (adc / 204.6); // Obtenemos lecturas de tension de 0 a 5V a partir de los valores del ADC

// Convertimos a string las variables adc y voltaje debido a que Serial.print solo admite un tipo de dato
// en este caso solo admite cadenas por lo que realizamos una concatenacion de dos cadenas "+"

 Serial.print("ADC = " + String(adc));   
 Serial.println("|  Voltaje = " + String(voltaje));
 delay(1500);

}

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!