Arduino Digital Voltmeter

Digital Voltmeter

Introduction

This experiment shows how to build a simple digital voltmeter using an Arduino to measure voltage and display it on an LCD.

Digital Voltmeter

Components Needed

Circuit Setup

  1. Connect the LCD to the Arduino using the I2C pins (SDA and SCL).
  2. Connect the voltage divider to analog input pin A0 to measure the input voltage.

Ensure the voltage divider is properly configured to scale the input voltage.

Digital Voltmeter Setup

Code for Digital Voltmeter

Upload the following code to your Arduino to measure voltage and display it on the LCD:


#include 
#include 

LiquidCrystal_I2C lcd(0x27, 16, 2);
const int analogPin = A0;
float voltage;

void setup() {
  lcd.begin();
  lcd.print("Digital Voltmeter");
  delay(2000);
}

void loop() {
  int sensorValue = analogRead(analogPin);
  voltage = sensorValue * (5.0 / 1023.0);
  lcd.clear();
  lcd.print("Voltage: ");
  lcd.print(voltage);
  lcd.print(" V");
  delay(1000);
}
            

Explanation

The code reads the voltage from the analog input pin, converts it into a corresponding voltage value, and displays it on the LCD.

Troubleshooting