list of products from Amazon (Not mine, i just link them!) Scroll Down For Article! Note: Elegoo boards are not Arduino, but they are compatible with Arduino IDE and are mutch more affordable!
Description of the Arduino Voltmeter Code
This Arduino code creates a simple voltmeter capable of measuring voltages from 0 to 5 volts using an LCD 1602 display with I2C communication. The program utilizes the Wire library for I2C communication and the LiquidCrystal_I2C library to manage the LCD display. The positive side of the voltage is connected to analog input A3, where the Arduino reads the voltage value.
In the setup()
function, serial communication is initialized at 9600 baud, the LCD display is set up, and the backlight is turned on. The loop()
function continuously reads the analog voltage from pin A3, calculates the corresponding voltage (with 1023 representing 5 volts), and displays this value on both the Serial Monitor and the LCD. The readings are updated every half second, with the LCD cleared between updates to ensure clarity.
This project is an excellent introduction to using Arduino for voltage measurement and LCD display interfacing, making it a valuable resource for electronics enthusiasts and beginners.
SCHEMATIC:

CODE:
/*
In this example, we’ll use an Arduino to create
a simple voltmeter with a range of 0 to 5 volts.
*/
#include <Wire.h> // library for controlling devices via I2C
#include <LiquidCrystal_I2C.h> // library for using an LCD 1602 display
LiquidCrystal_I2C lcd(0x27,16,2); // define lcd variable for a 16x2 display
int Vpin = A3; // connect the positive side of the voltage to analog input A3
float voltage; // variable to hold raw analog value
float volts; // variable to hold calculated voltage value
void setup() // setup procedure runs once when the program starts
{
Serial.begin(9600); // initialize serial communication at 9600 baud rate
lcd.init(); // initialize the LCD display
lcd.backlight(); // turn on the LCD backlight
}
void loop() // loop procedure runs continuously
{
voltage = analogRead(Vpin); // read the voltage at pin A3
// calculate voltage based on the analog read (1023 corresponds to 5V)
volts = voltage / 1023 * 5.0;
Serial.println(volts); // print the voltage value to the Serial Monitor
lcd.print("Voltage = "); // display label for voltage reading
lcd.print(volts); // display calculated voltage on LCD
delay(500); // delay for half a second to stabilize the reading
lcd.clear(); // clear LCD display for the next reading
}
- Arduino projects
- Voltmeter tutorial
- Voltage measurement with Arduino
- LCD 1602 display
- I2C communication
- DIY electronics projects
- Arduino programming for beginners
- Analog input reading
- LiquidCrystal_I2C library
- Electronics projects for beginners
0 Comments