Good afternoon all,
So I want to make a voltmeter using Arduino UNO. whenever i use the internal voltage source (The 5V and 3.3V ) it gives me a kind of correct answer but whenever i use an external voltage source, ie a battery or a dc generator it gives me the max analog value (1023).
I am using a voltage divider with R1= 100Kohm and R2= 10Kohm
Here is the code.
int analogInput = A0;
int value = 0;
float R1=100000.0;
float R2=10000.0;
float R3=5.0;
float vin=0.0;
float vout=0.0;
float current=0.0;
void setup(){
pinMode(analogInput, INPUT);
Serial.begin(9600);
}
void loop(){
value = analogRead(analogInput);
vin= value*5.0/1023.0;
vout= vin/(R2/(R1+R2));
current = vout/R3;
Serial.println(vout);
delay(500);
}