Chapter 4 Keypad and LCD Interfacing

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 16

DIGITAL SYSTEMS IV

S1 2024

Chapter 3 Keypad and LCD


Interfacing

www.vut.ac.za

1
Interfacing Matrix Keypads
 When we want to interface one key to the microcontroller
then it needs one GPIO pin.
 But when we want to interface many keys like 9, 12 or
16 etc., then it may acquire all GPIO pins of
microcontroller.
 To save some GPIO pins of microcontroller, we can
use matrix keypad. Matrix keypad is nothing but keys
arrange in row and column.
 E.g. if we want to interface 16 keys to the
microcontroller then we require 16 GPIO pins but if we
use matrix 4x4 keypad then we require only 8 GPIO
pins of microcontroller.
Interfacing Matrix Keypads

 Keyboards are organized in a matrix of rows and columns. When a


key is pressed, a row and a column make a contact Otherwise;
there is no connection between rows and columns.
Interfacing Matrix Keypads
Specification of 4x4 keypad
 Key layout: 4 rows x 4 columns (16 keys total)

 Key Type: Membrane

 Operating voltage: 3V - 5V DC

 Interface: 8 digital pins (4 for rows, 4 for columns)

 Connector: Female 2.54mm Pitch

Application of 4x4 keypad


 4x4 keypads are widely used in various applications, here are a few

examples:
 Access Control Systems, Security Systems, Data Entry Systems,

Industrial Control Systems, Robotics, Electronic projects, etc.


Keypad Matrix Working
Scanning of Keys
 To detect a pressed key, the microcontroller grounds all rows by providing 0 to the output latch, and then it reads the columns
shown in above fig .

Scanning of Keys
 If the data read from columns is = 1111, no key has been pressed shown in
above fig. and the process continues till key press is detected.
 Now, consider highlighted key in above fig. is pressed. After pressing key, it
makes contact of row with column shown below.
Keypad Matrix Working

Scanning of Keys
 If one of the column bits has a zero, this means that a key press has occurred.
 For example, if C1:C4 = 1011, this means that a key in the C2 column has been
pressed.
 After detecting a key press, microcontroller will go through the process of identifying
the key.
This code blinks an LED connected to pin 13 ten times. The for loop iterates ten times (0 to 9), turning the LED on and off with a half-second delay between each state.

Process of Identifying the Key

Starting from the top row, the microcontroller will ground it by providing a low to row R1 only.
Now read the columns, if the data read is all 1s, no key in that row is pressed and the process continues for the next
row.
So, now ground the next row, R2. Read the columns, check for any zero and this process continues until the row is
identified.
E.g. In the above case, we will get row 2 in which column is not equal to 1111.
So, after identification of the row in which the key has been pressed we can easily find out the key by row and
column value.
This code blinks an LED connected to pin 13 ten times. The for loop iterates ten times (0 to 9), turning the LED on and off with a half-second delay between each state.

Exercises
 Explain the keypress detection mechanism for a 4x4 keypad
connected to a microcontroller
This code blinks an LED connected to pin 13 ten times. The for loop iterates ten times (0 to 9), turning the LED on and off with a half-second delay between each state.

LCD Screen Interfacing to Arduino


 A liquid crystal display, or LCD, is a video display that utilizes
the light modulating properties of liquid crystals to display
pictures or text on a screen. Since their invention in 1964,
 LCD screens have grown to be used in a very wide variety of
applications, including computer monitors, televisions, and
instrument panels.
 One way to utilize an LCD is with an Arduino microcontroller. By
wiring an Arduino microcontroller to the pins of an LCD display
it is possible to program the microcontroller to display a desired
text string or image on the screen
This code blinks an LED connected to pin 13 ten times. The for loop iterates ten times (0 to 9), turning the LED on and off with a half-second delay between each state.

LCD Screen Interfacing to Arduino


 A typical LCD display consists of 16 pins that control various features of the screen. A
table that shows the pins and describes each function can be seen in Table 1 below. The
 Arduino microcontroller can output voltages of either 5 V or 3.3 V, so the LCD can be
powered
 by wiring VSS and VDD to the ground and 5 V pins on the microcontroller. It is
possible to adjust
 the contrast of the screen by wiring a variable resistor to V0 located at pin 3 on the
screen. The
 RS, R/W, and E pins are wired to pins 12, ground, and 11 respectively on the Arduino.
The LCDthe pins and describes each function can be seen in Table 1 below.
 The Arduino microcontroller can output voltages of either 5 V or 3.3 V, so the LCD can
be powered by wiring VSS and VDD to the ground and 5 V pins on the microcontroller.
 It is possible to adjust the contrast of the screen by wiring a variable resistor to V0
located at pin 3 on the screen.
 The RS, R/W, and E pins are wired to pins 12, ground, and 11 respectively on the
Arduino.
This code blinks an LED connected to pin 13 ten times. The for loop iterates ten times (0 to 9), turning the LED on and off with a half-second delay between each state.

LCD Screen Interfacing to Arduino


 The LCD screen can operate in both 8-but mode and 4-bit. For this application note
only 4-bit mode will be discussed, as it requires fewer pins and is generally easier to
use
This code blinks an LED connected to pin 13 ten times. The for loop iterates ten times (0 to 9), turning the LED on and off with a half-second delay between each state.

LCD Screen Interfacing to Arduino


 To interface with the LCD in 4-bit mode the Arduino only needs
to be connected to pins DB4-DB7, which will connected to digital
output pins 5-2 respectively. Pins 15 and 16 on the
 LCD screen are used to power a backlight in the screen. This
makes text displayed in the screen easier to read in poorly lit
environments and is optional. In order to power the backlight
pin 15 should be connected to ground while pin 16 should be
connected to the 5 V output of the Arduino.
 To power the Arduino a 9 V battery can be connected to the VIn
and ground pins on the Arduino. If such power source is
available the Arduino can be powered by using its USB
 connection with a computer
This code blinks an LED connected to pin 13 ten times. The for loop iterates ten times (0 to 9), turning the LED on and off with a half-second delay between each state.

LCD Screen Interfacing to Arduino


 The LCDs have a parallel interface, meaning that the microcontroller has to
manipulate several interface pins at once to control the display. The interface consists
of the following pins:

 A register select (RS) pin that controls where in the LCD's memory you're writing
data to. You can select either the data register, which holds what goes on the screen, or
an instruction register, which is where the LCD's controller looks for instructions on
what to do next.
 A Read/Write (R/W) pin that selects reading mode or writing mode
 An Enable pin that 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.
 There's also a display contrast pin (Vo), power supply pins (+5V and GND) and
LED Backlight (Bklt+ and BKlt-) pins that you can use to power the LCD, control
the display contrast, and turn on and off the LED backlight, respectively.
LCD Screen Interfacing to Arduino
This code blinks an LED connected to pin 13 ten times. The for loop iterates ten times (0 to 9), turning the LED on and off with a half-second delay between each state.

LCD Exercise
 Understanding the function of each pin on the LCD module is important. Can you
explain the function of RS & RW pin
THANKYOU

Andries Potgieter Blvd. Vanderbijlpark, 1900 , South Africa | T 098 008 8900 | E enquiries@ vut. ac. za www.vut.ac.za
16

You might also like