16×2 Lcd Voltmeter

Hi there,

Recently i made a voltmeter which i found very interesting.So i decided to make a blog over it.

So here is it HOW I MADE IT<>?

Parts I Used :-

1 x Arduino Mega2560

1x LCD (Liquid Crystal Display)

1x 5 kohm potentiometer

1x breadboard

female connectors

jumper wires

 

Wiring Diagram

The 16×2 LCD used in this experiment has a total of 16 pins. As shown in the table below, eight of the pins are data lines (pins 7-14), two are for power and ground (pins 1 and 16), three are used to control the operation of LCD (pins 4-6), and one is used to adjust the LCD screen brightness (pin 3). The remaining two pins (15 and 16) power the backlight.

Terminal 1 GND
Terminal 2 +5V
Terminal 3 Mid terminal of Potentiometer (for brightness control)
Terminal 4 Resistor Select (RS)
Terminal 5 Read/Write (RW)
Terminal 6 Enable(EN)
Terminal 7 DB0
Terminal 8 DB1
Terminal 9 DB2
Terminal 10 DB3
Terminal 11 DB4
Terminal 12 DB5
Terminal 13 DB6
Terminal 14 DB7
Terminal 15 +4.2-5V
Terminal 16 GND

 

Refer to the diagram below to see how to connect the LCD to the Arduino. Note that the potentiometer is connected to the 5V source and GND and the middle terminal is connected to pin 3 of LCD. Rotating this pot changes the brightness of the LCD. The four data pins DB4-DB7 are connected to the Arduino pins 4-7. Enable is connected to pin 9 of the Arduino and RS is connected to pin 8 of the Arduino. RW is connected to ground. The backlight LED is connected to 5V and ground. The following table shows the pin connections:

DB4 —–>pin4

DB5 —–>pin5

DB6 —–>pin6

DB7 —–>pin7

RS   —–>pin8

EN   —–>pin9

 

Code

The program below uses the LiquidCrystal library. This library contains all of the functions needed to write to the LCD.

The loop reads the analog value from the the analog input, and because the reference voltage is 5 V, it multiples that value by 5, then divides by 1024 to calculate the actual voltage value. Once the voltage has been calculated, the value is written to the LCD.

The photo below shows a typical display.

#include “LiquidCrystal.h”

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

float input_voltage = 0.0;

float temp=0.0;

void setup()

{

Serial.begin(9600); // opens serial port, sets data rate to 9600 bps

lcd.begin(16, 2); //// set up the LCD’s number of columns and rows:

lcd.print(“DIGITAL VOLTMETER”);

}

void loop()

{ //Conversion formula for voltage

int analog_value = analogRead(A0);

input_voltage = (analog_value * 5.0) / 1024.0;

if (input_voltage < 0.1)

{ input_voltage=0.0; }

Serial.print(“v= “);

Serial.println(input_voltage);

lcd.setCursor(0, 1);

lcd.print(“Voltage= “);

lcd.print(input_voltage);

delay(300);

}

Have a look on my Voltmeter::::