16*2 Lcd Arduino Display

by manang7 in Circuits > Arduino

2456 Views, 1 Favorites, 0 Comments

16*2 Lcd Arduino Display

WhatsApp Image 2021-06-17 at 7.44.37 PM.jpeg

LCD is an electronic component used to display content in the form of texts and images.LCD is also known as Liquid Crystal Display is an inexpensive display commonly used to display data.
In this tutorial, you will learn how to use an LCD 16x2 display to display simple text.

Hardware Requirements

Software Requirements

Pins Used

Screenshot (70).png
Screenshot (66).png

The parallel interface consists of the following pins:

  • Power Supply pins (Vss/Vcc): Power the LCD
  • Contrast pin (Vo): Control the display contrast
  • Register Select (RS) pin: Controls wherein the LCD's memory you're writing data to
  • Read/Write (R/W): Selects reading mode or writing mode
  • Enable pin: Enables writing to the registers
  • 8 data pins (D0 -D7): The states of these pins (high or low) are the bits that you're writing to a register when you write or the values you're reading when you read.
  • Backlight (Bklt+ and BKlt-) pins: Turn on/off the LED backlight

Code

#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
 
 lcd.begin(16, 2);
 
}

void loop() {
 
 
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Hello Witblox's");
  lcd.setCursor(0, 1);
  lcd.print("LCD CODE");
delay(500);
}

Let's Understand the Code

We first import the LCD Library

#include <LiquidCrystal.h>

Create a variable of LiquitCrystal

Syntax - LiquidCrystal(rs, enable, d4, d5, d6, d7)

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

lcd.begin() command sets up the LCD number of columns and rows.If the lcd has 16 columns and 3 rows the

lcd.begin(16,3)

lcd.begin(16,2);

lcd.clear() is a function that clears the lcd screen and sets the cursor in the upper left corner.

lcd.clear();

lcd.setCursor(x,y) is a function that takes coordinates of the x i.e is row and y is column.

In this case there are two rows - (0,1) so the x can have two values i.e 0 means first row and 1 means second row.

Similarly y i.e columns can bear values from 0 to 15.

lcd.setCursor(0, 0) means row zero and column zero.

lcd.setCursor(0, 0);

lcd.print("--message--") command print a message

lcd.print("Hello Witblox's");

Why Do We Need the Potentiometer?

It is used to set the contrast of the screen. As lighting differs in different conditions we need to set contrast according to it. So not necessarily you will require a potentiometer to get the message printed but if you don't try using a potentiometer.

Download the whole code here

In the next session, we will learn to display sensor data

Downloads