In this article, I’ll be explaining the interfacing of an LCD and a potentiometer with Arduino.
We had chosen to use Arduino Board for our project because it was simplest to work with.
Interfacing an LCD display with Arduino was the foremost task that we did in this project.
The schematic for Interfacing display is given below :
The connections between LCD and Arduino are:
LCD Pin Name | LCD Pin Number | Arduino Pin |
1 | Vss | GND |
2 | Vdd | +5V |
3 | V0 | GND |
4 | Rs | D12 |
5 | R/W | GND |
6 | E | D8 |
7 | DB0 | No Connection |
8 | DB1 | No Connection |
9 | DB2 | No Connection |
10 | DB3 | No Connection |
11 | DB4 | D5 |
12 | DB5 | D4 |
13 | DB6 | D13 |
14 | DB7 | D2 |
15 | LED+ | +5V with a 220 Ohm Resistor in series |
16 | LED- | GND |
The code for running a Hello World to make sure that the LCD is properly interfaced is as follows :
#include <LiquidCrystal.h> const int rs = 12, en = 8, d4 = 5, d5 = 4, d6 = 13, d7 = 2; LiquidCrystal lcd(rs, en, d4, d5, d6, d7); void setup() { lcd.begin(16, 2); lcd.setCursor(2, 0); lcd.print("Hello World"); delay(1000); } void loop() { lcd.setCursor(2,1); lcd.print("Hello World"); }
Adding a Potentiometer to change the set temperature, and displaying it on LCD :
We connect the variable terminal of a 22 Kilo Ohm Potentiometer to Pin A0 of the Arduino, and the fixed terminals to GND and +5V.
The user can change the set temperature by varying the knob position.
The code used for capturing the set temperature from a potentiometer and then displaying it on LCD is :
#include <LiquidCrystal.h> const int rs = 12, en = 8, d4 = 5, d5 = 4, d6 = 13, d7 = 2; int temp=0; int temp1=0; float potchange=0; int sensorPin=A0; LiquidCrystal lcd(rs, en, d4, d5, d6, d7); void setup() { lcd.begin(16, 2); } void loop() { temp=analogRead(sensorPin); potchange=temp; temp1=15+(temp/1023.0)*41.0; //Maps change in pot wiper between integers 15 to 56 lcd.setCursor(0, 0); lcd.print("Set Temp: "); lcd.setCursor(10, 0); lcd.print(temp1); }
You can download the above Arduino Codes from here :
1 thought on “Interfacing Display and Potentiometer to Arduino”