Devices & Components
Arduino Uno Rev3
Resistor 1M ohm
Breadboard (generic)
Jumper wires (generic)
Through Hole Resistor, 33 kohm
Software & Tools
Arduino IDE
Project description
Code
arduino voltmeter code
arduino
this code will work only if the resistor value is approx. similar to the shown
1float input_volt = 0.0; 2float temp = 0.0; 3float r1 = 33000.0; 4float r2 = 840000.0; 5 6void setup() 7{ 8 Serial.begin(9600); 9} 10 11void loop() 12{ 13 14 int analogvalue = analogRead(A2); 15 temp = (analogvalue * 5.0) / 1024.0; 16 input_volt = temp / (r2 / (r1 + r2)); 17 if (input_volt < 0.1) 18 { 19 input_volt = 0.0; 20 } 21 Serial.print("Volts = "); 22 Serial.println(input_volt); 23 24 delay(100); 25 26 27}
arduino voltmeter code
arduino
this code will work only if the resistor value is approx. similar to the shown
1float input_volt = 0.0; 2float temp = 0.0; 3float r1 = 33000.0; 4float 5 r2 = 840000.0; 6 7void setup() 8{ 9 Serial.begin(9600); 10} 11 12void 13 loop() 14{ 15 16 int analogvalue = analogRead(A2); 17 temp = (analogvalue 18 * 5.0) / 1024.0; 19 input_volt = temp / (r2 / (r1 + r2)); 20 if (input_volt 21 < 0.1) 22 { 23 input_volt = 0.0; 24 } 25 Serial.print("Volts = "); 26 27 Serial.println(input_volt); 28 29 delay(100); 30 31 32}
Downloadable files
circuit diagram of arduino voltmeter
the sketch has been made on Proteus IDE
circuit diagram of arduino voltmeter

Comments
Only logged in users can leave comments