DIY Projects

Interfacing Potentiometer and LCD with Arduino

Statement of the problem

In this article, we are going to see the interface of a Potentiometer and LCD with Arduino. Interfacing the potentiometer is the main concept of most of the interfacing of any analog sensor to the Arduino. In the real world, most analog sensors produce the output in terms of voltage. 

This article will help the reader to interface any analog sensor with Arduino. There are two different programs given for the same schematic. It will give the understanding to the reader to convert any analog quality to the corresponding units.

Schematic of interfacing potentiometer and LCD with Arduino

Interfacing Potentiometer and LCD with Arduino 1

Connection diagram of Arduino with LCD and Pot

Interfacing Potentiometer and LCD with Arduino 2

Arduino UNO connection with Potentiometer and LCD

Code-1: Code for interfacing Potentiometer and LCD with Arduino (DIRECT READING)

#include<LiquidCrystal.h>    

intsensorread = 0;  //Analog Input Variable

float Volt =0;        //Actual Output Variable

// Set up the library with the interface pin numbers.

LiquidCrystallcd(12, 11, 5, 4, 3, 2);

voidsetup()

{

  pinMode(A0, INPUT);   //Declaration of Analog Input

  // set up the LCD’s number of columns and rows:

  lcd.begin(16, 2);

  Serial.begin(9600);

}

voidloop()

{

  // read the input on analog pin 0:

  sensorread = analogRead(A0);

  // set the cursor to column 0, line 0:

  lcd.setCursor(0, 0);

  // print out the value at LCD Display:

  lcd.print(“Analog Read:”);

  lcd.print(sensorread);

  // print out the value at Serial Monitor:

  Serial.println(sensorread);

  delay(1000);

  lcd.clear();  

}

Code-2: Code for interfacing Potentiometer and LCD with Arduino (UNIT CONVERSION)

#include<LiquidCrystal.h>    

intsensorread = 0;  //Analog Input Variable

float Volt =0;        //Actual Output Variable

// Set up the library with the interface pin numbers. 

LiquidCrystallcd(12, 11, 5, 4, 3, 2);

voidsetup()

{

  pinMode(A0, INPUT);   //Declaration of Analog Input

  // set up the LCD’s number of columns and rows:

  lcd.begin(16, 2);

  Serial.begin(9600);

}

voidloop()

{

  // read the input on analog pin 0:

  sensorread = analogRead(A0);

  // set the cursor to column 0, line 0:

  lcd.setCursor(0, 0);

  // print out the value at LCD Display:

  lcd.print(“Analog Read:”);

  lcd.print(sensorread);

lcd.print(“Voltage:”);

  lcd.print(Volt);

  // print out the value at Serial Monitor:

  Serial.println(sensorread);

  delay(1000);

  lcd.clear();  

}

Circuit Explanation

This project consists of an Arduino UNO board, LCD, and Potentiometer(10K). 

Interfacing Potentiometer and LCD with Arduino 3

The process of controlling the display involves putting the data display into the data registers, and then putting instructions in the instruction register.

Pinout Details of 16X2 LCD Display

PinsNameDescriptionPinsNameDescription
1VSSPower supply (GND)9D2Data bus line 2
2VCCPower supply (+5V)10D3Data bus line 3
3VEEContrast adjusts11D4Data bus line 4
4RS0 = Instruction input
1 = Data input
12D5Data bus line 5
5R/W0 = Write to LCD Module
1 = Read from LCD module
13D6Data bus line 6
6ENEnable signal14D7Data bus line 7 (MSB)
7D0Data bus line 0 (LSB)15LEDALED Positive
8D1Data bus line 116LEDKLED Negative

Before wiring the LCD screen to the Arduino board, one should know the Arduino I/O to which I/O the LCD should connected.

Connect the following Arduino UNO boardpins to LCD Display pins:

S. NoArduino UNOLCD
1Pin 12RS pin 
2Pin 11Enable pin
3Pin 5D4
4Pin 4D5
5Pin 3D6
6Pin 2D7
7GNDR/W, VSS, LED-
85VVCC, LED+

Additionally, wire a 10k potentiometer to +5V and GND, with its wiper (output) to LCD screens VEE pin (pin3).

The objective of the article is to monitor the analog signal. Apart from LCD, a 10K potentiometer is used to control the analog signal. The following image shows the connection of the potentiometer to Arduino.

Interfacing Potentiometer and LCD with Arduino 4

Code Explanation

Interfacing the Arduino with LCD and Potentiometer has five sections

In this article the first section is the declaration of the header file. Since the project used LCD interfacing. 

Interfacing Potentiometer and LCD with Arduino 6

Section two consists of a declaration of variables used in the project. The Sensorread variable is for reading the Analog pin (in this project A0 is used). The variable Volt is used for displaying the Analog input with the corresponding unit (here voltage is used) inLCD.

Interfacing Potentiometer and LCD with Arduino 7

In Section three the LCD library is declared with the pin number of the Arduino

Interfacing Potentiometer and LCD with Arduino 8

Now, the declaration of the main function used in the project. Such as Input and output functions. Here the Input is Analog and the output is displayed. The Arduino UNO consists of 6 Analog inputs (A0, A1…A5) In this project, A0 Analog input is used for reading the analog data

Interfacing Potentiometer and LCD with Arduino 9

Final, Section consists of the task that Arduino UNO going to perform. The objective of the project is to read the Analog data and display it in LCD. Therefore, the sensorread variable is declared with analogRead(A0) function. 

The LCD functions such as lcd.setCursor, lcd.print, lcd.clear are used to perform the LCD operations like Starting position of text, print the variable, and clear the screen.

Interfacing Potentiometer and LCD with Arduino 10

Result

Direct reading of Analog data from the Potentiometer

Interfacing Potentiometer and LCD with Arduino 12

Voltage Measurement reading through the voltage conversion Formula By doing the above exercise the reader can able to do a potentiometer and LCD interface with Arduino.

Interfacing Potentiometer and LCD with Arduino 13

Sundareswaran Iyalunaidu

With over 24 years of dedicated experience, I am a seasoned professional specializing in the commissioning, maintenance, and installation of Electrical, Instrumentation and Control systems. My expertise extends across a spectrum of industries, including Power stations, Oil and Gas, Aluminium, Utilities, Steel and Continuous process industries. Tweet me @sundareshinfohe

Related Articles

Back to top button