Home Code Basic voltmeter

Basic voltmeter

by shedboy71

This is a basic LCD voltmeter example

YOU SHOULD NOT MEASURE MORE THAN 5v or reverse the polarity, you risk causing permanent damage to your Arduino

arduino voltmeter schematic

arduino voltmeter schematic

I tested a 1.5v battery, the reading was 1.50v, using a multimeter I read 1.58v, so not too shabby a reading.

Code
[c]
#include
#include

int analogValue = 0;
float voltage = 0;

// Connections: Sainsmart LCD/Keypad shield
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

void setup()
{
//Serial.begin(9600);
delay(1000);
//setup the LCD
lcd.begin(16, 2); // start the library
lcd.setCursor(0,0);
lcd.print(“Voltage”);
//Serial.begin(9600);

}

void loop()
{
analogValue = analogRead(1);
voltage = 0.0048*analogValue;

lcd.setCursor(0,1);
lcd.print(voltage);
delay(1000);

}

[/c]

Share

You may also like