Interfacing Liquid Crystal Display (LCD) – display data generated by sensor on LCD.

This project will demonstrate how to configure a 16 × 2 LCD screen to display numerous sensor values.

Hardware components required:-
  • Arduino UNO
  • Adafruit Standard LCD - 16x2 White on Blue
  • Rotary potentiometer (generic)
  • Jumper wires (generic)
  • Solderless Breadboard Full Size
  • RM065 10K ohm 103 Trim 
  • Pot Potentiometer
This project makes use of two potentiometers connected on a breadboard to an Arduino and an LCD. As a result, when both potentiometers are adjusted, the LCD should display their values.
Liquid Crystal Display (LCD)
Before we begin the configuration, let's take a closer look at the LCD and see what the 16 pins are for:
  • GND - Ground Connection
  • VCC - +5V Connection
  • VO - analogue pin used for screen brightness, connects to Potentiometer.
  • RS - tells the LCD what will be written to it.
  • R/W - the read/write pin (normally hardwired to ground).
  • E - tells the LCD the data is ready to be written.
  • D0 to D7 - bus lines for the LCD, this is where your data is passed from the Arduino to the LCD.
  • A - +5V Connection for the backlight of the LCD.
  • K - the ground pin for the backlight of the LCD.
Working:-

We may now begin building connections on and to the breadboard. A step-by-step approach is provided below:
  • Connect the 10K Ohm potentiometer (this potentiometer controls the LCD's contrast). The VO pin is linked to the potentiometer's center pin, while the other two wires are connected to +5V and ground on the breadboard.
  • Connect pin-A to the +5V and pin-K to ground on the breadboard.
  • Connect pin-D7 to digital pin 12, pin-D6 to digital pin 11, pin-D5 to digital pin 10 and pin-D4 to digital pin 9. (Digital pins on the Arduino).
  • Connect pin-RS to digital pin 7 on the Arduino.
  • Connect pin-RW to ground on the breadboard.
  • Connect pin-VSS to ground on the breadboard.
  • Connect pin-VDD to +5V on the breadboard.
  • Connect pin-E to digital pin 8 on the Arduino.
  • Place the first potentiometer on the board and connect the center pin to Analog Pin 1 on the Arduino and the other pins to ground and +5V on the breadboard.
  • Place the second potentiometer on the board and connect the center pin to Analog Pin 2 on the Arduino and the other pins to ground and +5V on the breadboard.
Connection Diagram:-

Display data generated by sensor on LCD.

The potentiometers that will be utilized are shown in the image below.


Code:-
  • Upload the code below to your Arduino and make any necessary adjustments to the potentiometers. 
  • The potentiometer values will be displayed on two lines on the LCD display. 
  • The B10K potentiometer can be adjusted to ensure that the contrast of the LCD is optimal for reading the values.
// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7,8,9,10,11,12);

int potPin1 = A1;
int potPin2 = A2;

void setup()
{
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
lcd.clear();

pinMode(potPin1, INPUT);
pinMode(potPin2, INPUT);
}

void loop()
{
lcd.setCursor(0,0); // Sets the cursor to col 0 and row 0
lcd.print("SensorVal1: "); // Prints Sensor Val: to LCD
lcd.print(analogRead(potPin1)); // Prints value on Potpin1 to LCD
lcd.setCursor(0,1); // Sets the cursor to col 1 and row 0
lcd.print("SensorVal2: "); // Prints Sensor Val: to LCD
lcd.print(analogRead(potPin2)); // Prints value on Potpin1 to LCD
}

Output Display:-

Interfacing Liquid Crystal Display



Post a Comment

Previous Post Next Post