You are on page 1of 13

Ministry of Higher Education and Scientific Research

University of Basrah
College of Engineering
Department of Electrical Engineering

{ LCD and Keypad }

Student Name : Mohammed Ismail Ahmed


Section and Roll No. : control – 29
Type of study : Evening study
LCD (Liquid Crystal Display) :
LCD (Liquid Crystal Display) is a type of flat panel
display which uses liquid crystals in its primary form of
operation. LEDs have a large and varying set of use
cases for consumers and businesses, as they can be
commonly found in smartphones, televisions, computer
monitors and instrument panels.
LCDs were a big leap in terms of the technology they
replaced, which include light-emitting diode (LED) and
gas-plasma displays. LCDs allowed displays to be much
thinner than cathode ray tube (CRT) technology. LCDs
consume much less power than LED and gas-display
displays because they work on the principle of blocking
light rather than emitting it. Where an LED emits light,
the liquid crystals in an LCD produces an image using a
backlight.
As LCDs have replaced older display technologies,
LCDs have begun being replaced by new display
technologies such as OLEDs.

How LCDs work

A display is made up of millions of pixels. The quality of


a display commonly refers to the number of pixels; for
example, a 4K display is made up of 3840 x2160 or
4096x2160 pixels. A pixel is made up of three subpixels;
a red, blue and green—commonly called RGB. When the
subpixels in a pixel change color combinations, a
different color can be produced. With all the pixels on a
display working together, the display can make millions
of different colors. When the pixels are rapidly switched
on and off, a picture is created.
The way a pixel is controlled is different in each type of
display; CRT, LED, LCD and newer types of displays all
control pixels differently. In short, LCDs are lit by a
backlight, and pixels are switched on and off
electronically while using liquid crystals to rotate
polarized light. A polarizing glass filter is placed in front
and behind all the pixels, the front filter is placed at 90
degrees. In between both filters are the liquid crystals,
which can be electronically switched on and off.
LCDs are made with either a passive matrix or an active
matrix display grid. The active matrix LCD is also
known as a thin film transistor (TFT) display. The
passive matrix LCD has a grid of conductors with pixels
located at each intersection in the grid. A current is sent
across two conductors on the grid to control the light for
any pixel. An active matrix has a transistor located at
each pixel intersection, requiring less current to control
the luminance of a pixel. For this reason, the current in
an active matrix display can be switched on and off more
frequently, improving the screen refresh time.
Some passive matrix LCD's have dual scanning, meaning
that they scan the grid twice with current in the same
time that it took for one scan in the original technology.
However, active matrix is still a superior technology out
of the two.
What is the LCD used for ?
LCDs are commonly used for portable electronic games,
as viewfinders for digital cameras and camcorders, in
video projection systems, for electronic billboards, as
monitors for computers, and in flat-panel televisions .

LCD linking way :


Hardware interfacing:

It has 16 pins and the first one from left to right is the Ground
pin. The second pin is the VCC which we connect the 5 volts
pin on the Arduino Board. Next is the Vo pin on which we can
attach a potentiometer for controlling the contrast of the display.
Next, The RS pin or register select pin is used for selecting
whether we will send commands or data to the LCD. For
example, if the RS pin is set on low state or zero volts, then we
are sending commands to the LCD like: set the cursor to a
specific location, clear the display, turn off the display and so
on. And when RS pin is set on High state or 5 volts we are
sending data or characters to the LCD. Next is the E pin which
enables the writing to the registers, or the next 8 data pins from
D0 to D7. So through this pins we are sending the 8 bits data
when we are writing to the registers or for example if we want
to see the latter uppercase A on the display we will send 0100
0001 to the registers according to the ASCII table. And the last
two pins A and K, or anode and cathode are for the LED back
light .

Software :
After all we don’t have to worry much about how the LCD
works, as the Liquid Crystal Library takes care for almost
everything. From the Arduino’s official website you can find
and see the functions of the library which enable easy use of the
LCD. We can use the Library in 4 or 8 bit mode. We will use it
in 4-bit mode, or we will just use 4 of the 8 data pins. We will
use just 6 digital input pins from the Arduino Board. The LCD’s
registers from D4 to D7 will be connected to Arduino’s digital
pins from 4 to 7. The Enable pin will be connected to pin
number 2 and the RS pin .
Keypad

Introduction :

Keypads are used in all types of devices, including cell phones,


fax machines, microwaves, ovens, door locks, etc. They’re
practically everywhere. Tons of electronic devices use them for
user input. So knowing how to connect a keypad to a
microcontroller such as an Arduino is very valuable for building
many different types of commercial products. The type of
keypad we will use is a matrix keypad. This is a keypad that
follows an encoding scheme that allows it to have much less
output pins than there are keys. For example, the matrix keypad
we are using has 16 keys (0-9, A-D, *, #), yet only 8 output
pins. With a linear keypad, there would have to be 17 output
pins (one for each key and a ground pin) in order to work.
Hardware Interface:- Figure bellow pinout of a standard keypad,
all 8 pins should be connected to Arduino digital pins .

A keypad is a block or pad of buttons set with an arrangement of


digits, symbols, or alphabetical letters. Pads mostly containing
numbers and used with computers are numeric keypads.
Keypads are found on devices which require mainly numeric
input such as calculators, television remotes, push-button
telephones, vending machines, ATMs, Point of
Sale devices, combination locks, and digital door locks. Many
devices follow the E.161 standard for their arrangement.
Projects :
Proj1 : connect the 16*2 LCD, then write program to read messages
from serial monitor and display on the LCD. When the message takes all
available character space, the LCD should be cleared ?

// initialize the library with the numbers of the interface pins

#include < LiquidCrystal.h>

LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

const byte ROWS = 4;

const byte COLS = 4;

char hexaKeys[ROWS][COLS] = {

{'1', '2', '3', 'A'},

{'4', '5', '6', 'B'},


{'7', '8', '9', 'C'},

{'*', '0', '#', 'D'}

};

byte rowPins[ROWS] = {8, 9, 10, 11};

byte colPins[COLS] = {A1, A2, A3, A4};

Keypad customKeypad = Keypad(makeKeymap(hexaKeys),

rowPins, colPins, ROWS, COLS);

char customKey;

void setup() {

Serial.begin(9600);

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

lcd.begin(16, 2);

void loop() {

customKey = customKeypad.getKey();

lcd.setCursor(0, 0);

lcd.print("Pressed Key");

if (customKey){ lcd.setCursor(0, 1);

lcd.print(customKey);

Serial.print("Pressed Key: ");

Serial.println(customKey);

}
Proj2: connect the 4*4 keypad, then write program to read messages
from the keypad and display on the LCD. When the message takes all
available character space, the LCD should be cleared.

#include < LiquidCrystal.h>

LiquidCrystal lcd(5, 4, 3, 2, A4, A5);

const byte ROWS = 4;

const byte COLS = 4;

char keys[ROWS][COLS] =

{ {‘1’,’2’,’3’,’A;},

{‘4’,’5’,’6’,’B’},

{‘7’,’8’,’9’,’C’},

{‘*’,’0’,’#’,’D’} };

byte rowPins[ROWS] = { A0,A1,11,10};

bytes colPins[COLS] = {9,8,7,6};


int LCDRow = 0;

int count_value=0;

Keypad keypad = Keypad( makeKeymap (keys), rowPins , colPins, ROWS,


COLS);

vaid setup() {

Serial.begin(9600);

lcd.begin(16, 2);

lcd.setCursor(LODROW,0);

void loop() {

char key = keypad getKey ();

if (key)

{lcd.print(key);

lcd.setCursor (++LCDRow, 0);

count_value++;

if (count_value == 17)

{Lcd.clear();}}}
Proj3: design MCU system to control 4 leds (turning them on/off),
keypad is used to enter the control command? When a new command is
entered, it should be displayed on LCD ?
#include

#include

const byte LED1 = 9;

const byte LED2 = 10;

const byte LED3 = 11;

const byte LED4 = 12;

byte myLEDis =255;

const byte ROWS = 4;

const byte COLS = 3;

char keys[ROWS] [COLS] = {

{'1', '2', '3'},

{'1', '4','5', '6'},

{'17','8', '9'},

{'*', '0','#'} };

byte rowPins[ROWS] = {8, 7, 6, 5};

byte colPins[COLS] = {4, 3, 2};

Keypad keypad = Keypad makeKeynap(keys), rowPins, colPins, ROWS, COLS );

void setup() {

Wire.begin();

Serial.begin(9600);

pinMode(LED1, OUTPUT);

pinMode(LED2, OUTPUT);

pinMode(LED3, OUTPUT);

pinMode(LED4, OUTPUT);

}
void loop() {

char key = keypad.getKey();

switch (key)

case '1': myLEDis = LED1;

break; case '2': myLEDis = LED2;

break; case '3' : myLEDis = LED3;

break; case '4': myLEDis = LED4;

break; case '# ': if (myLEDis !=255) { digitalWrite(myLEDis, HIGH);

break;

case '* ': if (myLEDis !=255) digitalWrite(myLEDis, LOW);

break ;

You might also like