SlideShare ist ein Scribd-Unternehmen logo
1 von 16
Downloaden Sie, um offline zu lesen
Keypad Interfacing
with 8051
Sudhanshu Janwadkar
S. V. National Institute of Technology
Lecture Notes: 9-10th April 2018
Points to discuss
• What is a matrix keypad?
• Schematic of 4 X 4 Matrix Keypad
• Principle of Operation – i.e How do we interface?
Introduction
• A 4 X 4 matrix keypad is called so because,
 it is organized in matrix structure
 It has 4X4=16 switches (i.e. push buttons)
• It can be used to give multiple inputs
• Each input can have some significance.
 If we use two ports of microcontroller, we can
connect 8X8 keypad. This can be used to give 64
inputs, which would have been only 16, if we
connect switches directly.
• A matrix keypad is
 Easy to interface
 Easy to procure
Introduction
• Keyboards are organized in a matrix of rows and columns
• The CPU accesses both rows and columns through ports
• When a key is pressed, a row and a column make a contact
• Otherwise, there is no connection between rows and
columns
Schematic of a 4 X 4 Keypad
• There are a total of 16 switches arranged in 4 rows and 4
columns
• Each row and column has a switch, in between, strategically
placed such that
 Each switch has the capability, if pressed, to short the
particular row and column (and form a path)
• The other paths would remain open
Schematic of a 4 X 4 Keypad
• Each switch can actually generate a unique situation of rows and
columns.
• For example, say SW1 is pressed. This would form a path between
Row1 and Column1. No other row and column would have a path.
Principle of operation
• Connect all rows to VDD through pull-up resistors. This means anytime you
read the logic level across rows, it would be ‘1111’.
• Connect Column 1 is at Logic 0(Ground), column 2 to VDD , column 3 to VDD
and column 4 to VDD
• If the user presses switch SW1, only row 1 will be connected to Column 1 and
it would be grounded. The other three rows would be at 5V. The row
information would be read 0111.
• Instead if the user presses, SW9, only Row3 would be grounded and
remaining rows be at VDD; row information would be read as 1101.
• If you have information about status of all the rows and column, you have
enough information to deduce or calculate, which switch has been pressed.
Principle of operation
• Note that, The rows and columns are just a convention and are absolutely
interchangeable. This would necessarily mean that rows can behave as
columns and columns can behave as rows.
• Grounding column 1, connecting the other three columns to VDD and then
reading row information would help you detect if any of the switches in
Column1 has been pressed.
• Extending the logic, to detect a switch press in Column2, you would have to
ground Column2 and connect the other columns to VDD. Reading the row
information would help you detect if SW2,SW6,SW10 or SW14 was pressed
and so on
• Lets build the general algorithm based on this information.
• Connect the 4X4 matrix keypad to the 8 pins of the microcontroller or
arduino or FPGA
• As said earlier, since the rows and columns are interchangeable, you
may vary the pattern you apply on columns and read the row
information. Or you may vary the row information and read the
columns.
Principle of operation
• If no switch is pressed, the rows would read 1111.
• Apply the pattern 0111 to the columns and read all the rows.
• The pattern 0111 on rows indicates SW1 is pressed. Pattern 1011
indicates SW4 is pressed. Pattern 1101 indicates Sw7 is pressed. Pattern
1110 indicates Sw* is pressed
• Next apply the pattern 1011 to the columns and read all rows, to detect if a
switch has been pressed in column2.
• Similarly, apply the pattern 1101 to the columns and read all rows, to detect
if a switch has been pressed in column3
• Similarly, apply the pattern 1110 to the columns and read all rows, to detect
if a switch has been pressed in column4
• Repeat the above steps at a very fast rate, so that none of the key press goes
undetected.
Summarizing,
• It is the function of the microcontroller to scan the
keyboard continuously to detect and identify the key
pressed
• To detect a pressed key, the microcontroller grounds all
columns, successively, by providing 0 and then it reads
the rows
• If the data read from rows is 1111, no key has been
pressed and the process continues till key press is
detected
• If one of the row bits has a zero, this means that a key
press has occurred
• After detecting a key press, microcontroller will go
through the process of identifying the key
Principle of operation
Summarizing,
• Starting with the Column 1, the microcontroller grounds
it by providing a low to Column C0 only
 It reads all the rows.
 If the data read is all 1s, no key in that row is
activated and the process is moved to the next
column
• It grounds the next column, reads all the rows and
checks for any zero
• This process continues until the column in which key is
pressed is identified
 After identification of the column in which the key
has been pressed, Find out which row the pressed
key belongs to
Principle of operation
ORG 00H
MOV DPTR, #LUT // The 7-segment codes of switch press detected are stored in Code memory
MOV P0, #00000000B // initializes P0 as output port; 7-segment is connected to Port 0
;------------CONNECTIONS------------------
;P1.0 = Col 0, P1.1 = Col 1, P1.2 = Col 2, P1.3 = Col 3,
;P1.4 = Row 0, P1.5 =Row 1 P1.6 = Row 2, P1.7 = Row 3,
BACK:
CLR P1.0 // makes Column 0 low,; col 1, col2 and col3 = 1
JB P1.4,NEXT1 // checks whether Row 0 is low and jumps to NEXT1 if not low
MOV A,#1D // Row0 =0 when Col 0 =0,indicates that SW1 has been pressed. Display 1
ACALL DISPLAY // calls DISPLAY subroutine
NEXT1:JB P1.5,NEXT2 // checks whether Row 1 is low. Row 1 =0 indicates SW2 has been pressed.
MOV A,#2D // Display 2
ACALL DISPLAY
NEXT2:JB P1.6,NEXT3// Check whether Row2 is low
MOV A,#3D //Display 3
ACALL DISPLAY
NEXT3:JB P1.7,NEXT4//Check if Row 3 is low
MOV A,#10 D //Display A
ACALL DISPLAY
; This completed one set of Row checking
With Col0 =0. Next make Col0 =1 and col1=0,
Col2 =1 and col3=1, as earlier
1 4 7 D
2 5 8 E
3 6 9 F
A B C 0
P1.0 P1.1 P1.2 P1.3
P1.4
P1.5
P1.6
P1.7
Each keypad would have same internal connections, But the numbers displayed on top
might vary. This code will work only for the keypad display shown
; column information = 1011, read rows
NEXT4:SETB P1.0
CLR P1.1
JB P1.4,NEXT5
MOV A,#4D
ACALL DISPLAY
NEXT5:JB P1.5,NEXT6
MOV A,#5D
ACALL DISPLAY
NEXT6:JB P1.6,NEXT7
MOV A,#6D
ACALL DISPLAY
NEXT7:JB P1.7,NEXT8
MOV A,#11D
ACALL DISPLAY
; column information = 1101, read rows
NEXT8:SETB P1.1
CLR P1.2
JB P1.4,NEXT9
MOV A,#7D
ACALL DISPLAY
NEXT9:JB P1.5,NEXT10
MOV A,#8D
ACALL DISPLAY
NEXT10:JB P1.6,NEXT11
MOV A,#9D
ACALL DISPLAY
NEXT11:JB P1.7,NEXT12
MOV A,#12D
ACALL DISPLAY
1 4 7 D
2 5 8 E
3 6 9 F
A B C 0
P1.0 P1.1 P1.2 P1.3
P1.4
P1.5
P1.6
P1.7
; column information = 1110, read rows
NEXT12:SETB P1.2
CLR P1.3
JB P1.4,NEXT13
MOV A,#13D
ACALL DISPLAY
NEXT13:JB P1.5,NEXT14
MOV A,#14D
ACALL DISPLAY
NEXT14:JB P1.6,NEXT15
MOV A,#15D
ACALL DISPLAY
NEXT15:JB P1.7,BACK
MOV A,#0D
ACALL DISPLAY
LJMP BACK
;DPTR points to first location of LUT. Accumulator contains the offset value to be added. Fetch the
byte containing the Seven segment code from LUT (in Code memory) and display
DISPLAY:
MOVC A,@A+DPTR //
MOV P0,A // puts corresponding digit drive pattern into P0
RET
LUT:
// Look up table starts here
DB 11111100B //0… abcdefgh
DB 01100000B //1
DB 11011010B //2
DB 11110010B //3
DB 01100110B //4
DB 10110110B
DB 10111110B
DB 11100000B
DB 11111110B
DB 11110110B
DB 11101110B
DB 00111110B
DB 10011110B
DB 01111010B
DB 10011110B
DB 10011110B //F
END

Weitere ähnliche Inhalte

Was ist angesagt?

Architecture of 8085 microprocessor
Architecture of 8085 microprocessorArchitecture of 8085 microprocessor
Architecture of 8085 microprocessorAMAN SRIVASTAVA
 
7 segment led interfacing with 8051
7 segment led interfacing with 80517 segment led interfacing with 8051
7 segment led interfacing with 8051Sam Patel
 
Key board interfacing with 8051
Key board interfacing with 8051Key board interfacing with 8051
Key board interfacing with 8051DominicHendry
 
8051 Microcontroller ppt
8051 Microcontroller ppt8051 Microcontroller ppt
8051 Microcontroller pptRahul Kumar
 
Interfacing memory with 8086 microprocessor
Interfacing memory with 8086 microprocessorInterfacing memory with 8086 microprocessor
Interfacing memory with 8086 microprocessorVikas Gupta
 
Digital electronics logic families
Digital electronics logic familiesDigital electronics logic families
Digital electronics logic familiesBLESSINAR0
 
Subroutine in 8051 microcontroller
Subroutine in 8051 microcontrollerSubroutine in 8051 microcontroller
Subroutine in 8051 microcontrollerbhadresh savani
 
MICROCONTROLLER 8051- Architecture & Pin Configuration
MICROCONTROLLER 8051- Architecture & Pin Configuration MICROCONTROLLER 8051- Architecture & Pin Configuration
MICROCONTROLLER 8051- Architecture & Pin Configuration AKHIL MADANKAR
 
Schmitt trigger circuit
Schmitt trigger circuitSchmitt trigger circuit
Schmitt trigger circuittaranjeet10
 
8051 Microcontroller I/O ports
8051 Microcontroller I/O ports8051 Microcontroller I/O ports
8051 Microcontroller I/O portsanishgoel
 
8257 DMA Controller
8257 DMA Controller8257 DMA Controller
8257 DMA ControllerShivamSood22
 
Architecture of 8051
Architecture of 8051Architecture of 8051
Architecture of 8051hello_priti
 

Was ist angesagt? (20)

Architecture of 8085 microprocessor
Architecture of 8085 microprocessorArchitecture of 8085 microprocessor
Architecture of 8085 microprocessor
 
7 segment led interfacing with 8051
7 segment led interfacing with 80517 segment led interfacing with 8051
7 segment led interfacing with 8051
 
LCD Interacing with 8051
LCD Interacing with 8051LCD Interacing with 8051
LCD Interacing with 8051
 
Key board interfacing with 8051
Key board interfacing with 8051Key board interfacing with 8051
Key board interfacing with 8051
 
Interrupts in 8051
Interrupts in 8051Interrupts in 8051
Interrupts in 8051
 
8051 Microcontroller ppt
8051 Microcontroller ppt8051 Microcontroller ppt
8051 Microcontroller ppt
 
Interfacing memory with 8086 microprocessor
Interfacing memory with 8086 microprocessorInterfacing memory with 8086 microprocessor
Interfacing memory with 8086 microprocessor
 
Digital electronics logic families
Digital electronics logic familiesDigital electronics logic families
Digital electronics logic families
 
Subroutine in 8051 microcontroller
Subroutine in 8051 microcontrollerSubroutine in 8051 microcontroller
Subroutine in 8051 microcontroller
 
MICROCONTROLLER 8051- Architecture & Pin Configuration
MICROCONTROLLER 8051- Architecture & Pin Configuration MICROCONTROLLER 8051- Architecture & Pin Configuration
MICROCONTROLLER 8051- Architecture & Pin Configuration
 
Intel 8051 - pin description
Intel 8051  - pin descriptionIntel 8051  - pin description
Intel 8051 - pin description
 
Schmitt trigger circuit
Schmitt trigger circuitSchmitt trigger circuit
Schmitt trigger circuit
 
8051 Microcontroller I/O ports
8051 Microcontroller I/O ports8051 Microcontroller I/O ports
8051 Microcontroller I/O ports
 
8257 DMA Controller
8257 DMA Controller8257 DMA Controller
8257 DMA Controller
 
8051 instruction set
8051 instruction set8051 instruction set
8051 instruction set
 
8086 micro processor
8086 micro processor8086 micro processor
8086 micro processor
 
Architecture of 8051
Architecture of 8051Architecture of 8051
Architecture of 8051
 
Adc interfacing
Adc interfacingAdc interfacing
Adc interfacing
 
I o ports.ppt
I o ports.pptI o ports.ppt
I o ports.ppt
 
Synchronous Counter
Synchronous Counter Synchronous Counter
Synchronous Counter
 

Ähnlich wie Keypad Interfacing with 8051 Microcontroller

Microcontroladores: El microcontrolador 8051 con LCD 16x2
Microcontroladores: El microcontrolador 8051 con LCD 16x2Microcontroladores: El microcontrolador 8051 con LCD 16x2
Microcontroladores: El microcontrolador 8051 con LCD 16x2SANTIAGO PABLO ALBERTO
 
UNIT 5 Interfacing and Mixed Signal Controller.pptx
UNIT 5 Interfacing and Mixed Signal Controller.pptxUNIT 5 Interfacing and Mixed Signal Controller.pptx
UNIT 5 Interfacing and Mixed Signal Controller.pptxGowrishankar C
 
Digital Electronics Unit_4_new.pptx
Digital Electronics Unit_4_new.pptxDigital Electronics Unit_4_new.pptx
Digital Electronics Unit_4_new.pptxThapar Institute
 
Keyboard Interfacing .pptx
Keyboard Interfacing .pptxKeyboard Interfacing .pptx
Keyboard Interfacing .pptxlivaunnoor
 
Micro c lab4(keypad)
Micro c lab4(keypad)Micro c lab4(keypad)
Micro c lab4(keypad)Mashood
 
8086 – CPU –Pin Diagram.pptx
8086 – CPU –Pin Diagram.pptx8086 – CPU –Pin Diagram.pptx
8086 – CPU –Pin Diagram.pptx5G8Rajendra
 
IC 8253 - Microprocessor
IC 8253 - Microprocessor IC 8253 - Microprocessor
IC 8253 - Microprocessor Vatsal N Shah
 
Elements of Industrial Automation Week 08 Notes.pdf
Elements of Industrial Automation Week 08 Notes.pdfElements of Industrial Automation Week 08 Notes.pdf
Elements of Industrial Automation Week 08 Notes.pdfTHANMAY JS
 
Registers and Counters.ppt
Registers and Counters.pptRegisters and Counters.ppt
Registers and Counters.pptVijay Bhadouria
 
Synchronous Sequential Logic Unit 4
Synchronous Sequential Logic Unit 4Synchronous Sequential Logic Unit 4
Synchronous Sequential Logic Unit 4Asif Iqbal
 
PROGRAMMABLE KEYBOARD AND DISPLAY INTERFACE(8279).pptx
PROGRAMMABLE KEYBOARD AND DISPLAY INTERFACE(8279).pptxPROGRAMMABLE KEYBOARD AND DISPLAY INTERFACE(8279).pptx
PROGRAMMABLE KEYBOARD AND DISPLAY INTERFACE(8279).pptxSanjayV73
 

Ähnlich wie Keypad Interfacing with 8051 Microcontroller (20)

Microcontroladores: El microcontrolador 8051 con LCD 16x2
Microcontroladores: El microcontrolador 8051 con LCD 16x2Microcontroladores: El microcontrolador 8051 con LCD 16x2
Microcontroladores: El microcontrolador 8051 con LCD 16x2
 
UNIT 5 Interfacing and Mixed Signal Controller.pptx
UNIT 5 Interfacing and Mixed Signal Controller.pptxUNIT 5 Interfacing and Mixed Signal Controller.pptx
UNIT 5 Interfacing and Mixed Signal Controller.pptx
 
UNIT 5.pptx
UNIT 5.pptxUNIT 5.pptx
UNIT 5.pptx
 
Digital Electronics Unit_4_new.pptx
Digital Electronics Unit_4_new.pptxDigital Electronics Unit_4_new.pptx
Digital Electronics Unit_4_new.pptx
 
Keyboard Interfacing .pptx
Keyboard Interfacing .pptxKeyboard Interfacing .pptx
Keyboard Interfacing .pptx
 
Micro c lab4(keypad)
Micro c lab4(keypad)Micro c lab4(keypad)
Micro c lab4(keypad)
 
8279 d
8279 d8279 d
8279 d
 
8086 – CPU –Pin Diagram.pptx
8086 – CPU –Pin Diagram.pptx8086 – CPU –Pin Diagram.pptx
8086 – CPU –Pin Diagram.pptx
 
Ring counter
Ring counterRing counter
Ring counter
 
Microcontroller- An overview
Microcontroller- An overviewMicrocontroller- An overview
Microcontroller- An overview
 
Unit 5
Unit 5Unit 5
Unit 5
 
IC 8253 - Microprocessor
IC 8253 - Microprocessor IC 8253 - Microprocessor
IC 8253 - Microprocessor
 
8051
80518051
8051
 
Elements of Industrial Automation Week 08 Notes.pdf
Elements of Industrial Automation Week 08 Notes.pdfElements of Industrial Automation Week 08 Notes.pdf
Elements of Industrial Automation Week 08 Notes.pdf
 
PLC
PLCPLC
PLC
 
Registers and Counters.ppt
Registers and Counters.pptRegisters and Counters.ppt
Registers and Counters.ppt
 
Dns module3 p3
Dns module3 p3Dns module3 p3
Dns module3 p3
 
Dns module3 p3_shift registers
Dns module3 p3_shift registersDns module3 p3_shift registers
Dns module3 p3_shift registers
 
Synchronous Sequential Logic Unit 4
Synchronous Sequential Logic Unit 4Synchronous Sequential Logic Unit 4
Synchronous Sequential Logic Unit 4
 
PROGRAMMABLE KEYBOARD AND DISPLAY INTERFACE(8279).pptx
PROGRAMMABLE KEYBOARD AND DISPLAY INTERFACE(8279).pptxPROGRAMMABLE KEYBOARD AND DISPLAY INTERFACE(8279).pptx
PROGRAMMABLE KEYBOARD AND DISPLAY INTERFACE(8279).pptx
 

Mehr von Sudhanshu Janwadkar

ASIC design Flow (Digital Design)
ASIC design Flow (Digital Design)ASIC design Flow (Digital Design)
ASIC design Flow (Digital Design)Sudhanshu Janwadkar
 
Fpga architectures and applications
Fpga architectures and applicationsFpga architectures and applications
Fpga architectures and applicationsSudhanshu Janwadkar
 
Introduction to 8051 Timer/Counter
Introduction to 8051 Timer/CounterIntroduction to 8051 Timer/Counter
Introduction to 8051 Timer/CounterSudhanshu Janwadkar
 
Architecture of the Intel 8051 Microcontroller
Architecture of the Intel 8051 MicrocontrollerArchitecture of the Intel 8051 Microcontroller
Architecture of the Intel 8051 MicrocontrollerSudhanshu Janwadkar
 
Introduction to Embedded Systems
Introduction to Embedded SystemsIntroduction to Embedded Systems
Introduction to Embedded SystemsSudhanshu Janwadkar
 
Interconnects in Reconfigurable Architectures
Interconnects in Reconfigurable ArchitecturesInterconnects in Reconfigurable Architectures
Interconnects in Reconfigurable ArchitecturesSudhanshu Janwadkar
 
Design and Implementation of a GPS based Personal Tracking System
Design and Implementation of a GPS based Personal Tracking SystemDesign and Implementation of a GPS based Personal Tracking System
Design and Implementation of a GPS based Personal Tracking SystemSudhanshu Janwadkar
 
Embedded Logic Flip-Flops: A Conceptual Review
Embedded Logic Flip-Flops: A Conceptual ReviewEmbedded Logic Flip-Flops: A Conceptual Review
Embedded Logic Flip-Flops: A Conceptual ReviewSudhanshu Janwadkar
 
Silicon on Insulator (SOI) Technology
Silicon on Insulator (SOI) TechnologySilicon on Insulator (SOI) Technology
Silicon on Insulator (SOI) TechnologySudhanshu Janwadkar
 

Mehr von Sudhanshu Janwadkar (20)

DSP Processors versus ASICs
DSP Processors versus ASICsDSP Processors versus ASICs
DSP Processors versus ASICs
 
ASIC design Flow (Digital Design)
ASIC design Flow (Digital Design)ASIC design Flow (Digital Design)
ASIC design Flow (Digital Design)
 
Fpga architectures and applications
Fpga architectures and applicationsFpga architectures and applications
Fpga architectures and applications
 
SPI Bus Protocol
SPI Bus ProtocolSPI Bus Protocol
SPI Bus Protocol
 
I2C Protocol
I2C ProtocolI2C Protocol
I2C Protocol
 
Introduction to 8051 Timer/Counter
Introduction to 8051 Timer/CounterIntroduction to 8051 Timer/Counter
Introduction to 8051 Timer/Counter
 
Intel 8051 Programming in C
Intel 8051 Programming in CIntel 8051 Programming in C
Intel 8051 Programming in C
 
Hardware View of Intel 8051
Hardware View of Intel 8051Hardware View of Intel 8051
Hardware View of Intel 8051
 
Architecture of the Intel 8051 Microcontroller
Architecture of the Intel 8051 MicrocontrollerArchitecture of the Intel 8051 Microcontroller
Architecture of the Intel 8051 Microcontroller
 
Introduction to Embedded Systems
Introduction to Embedded SystemsIntroduction to Embedded Systems
Introduction to Embedded Systems
 
CMOS Logic
CMOS LogicCMOS Logic
CMOS Logic
 
Interconnects in Reconfigurable Architectures
Interconnects in Reconfigurable ArchitecturesInterconnects in Reconfigurable Architectures
Interconnects in Reconfigurable Architectures
 
Introduction to FPGAs
Introduction to FPGAsIntroduction to FPGAs
Introduction to FPGAs
 
Design and Implementation of a GPS based Personal Tracking System
Design and Implementation of a GPS based Personal Tracking SystemDesign and Implementation of a GPS based Personal Tracking System
Design and Implementation of a GPS based Personal Tracking System
 
Embedded Logic Flip-Flops: A Conceptual Review
Embedded Logic Flip-Flops: A Conceptual ReviewEmbedded Logic Flip-Flops: A Conceptual Review
Embedded Logic Flip-Flops: A Conceptual Review
 
Pass Transistor Logic
Pass Transistor LogicPass Transistor Logic
Pass Transistor Logic
 
Memory and Processor Testing
Memory and Processor TestingMemory and Processor Testing
Memory and Processor Testing
 
Pass Transistor Logic
Pass Transistor LogicPass Transistor Logic
Pass Transistor Logic
 
Silicon on Insulator (SOI) Technology
Silicon on Insulator (SOI) TechnologySilicon on Insulator (SOI) Technology
Silicon on Insulator (SOI) Technology
 
VHDL Behavioral Description
VHDL Behavioral DescriptionVHDL Behavioral Description
VHDL Behavioral Description
 

Kürzlich hochgeladen

Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfSanaAli374401
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 

Kürzlich hochgeladen (20)

Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 

Keypad Interfacing with 8051 Microcontroller

  • 1. Keypad Interfacing with 8051 Sudhanshu Janwadkar S. V. National Institute of Technology Lecture Notes: 9-10th April 2018
  • 2. Points to discuss • What is a matrix keypad? • Schematic of 4 X 4 Matrix Keypad • Principle of Operation – i.e How do we interface?
  • 3. Introduction • A 4 X 4 matrix keypad is called so because,  it is organized in matrix structure  It has 4X4=16 switches (i.e. push buttons) • It can be used to give multiple inputs • Each input can have some significance.  If we use two ports of microcontroller, we can connect 8X8 keypad. This can be used to give 64 inputs, which would have been only 16, if we connect switches directly. • A matrix keypad is  Easy to interface  Easy to procure
  • 4. Introduction • Keyboards are organized in a matrix of rows and columns • The CPU accesses both rows and columns through ports • When a key is pressed, a row and a column make a contact • Otherwise, there is no connection between rows and columns
  • 5. Schematic of a 4 X 4 Keypad • There are a total of 16 switches arranged in 4 rows and 4 columns • Each row and column has a switch, in between, strategically placed such that  Each switch has the capability, if pressed, to short the particular row and column (and form a path) • The other paths would remain open
  • 6. Schematic of a 4 X 4 Keypad • Each switch can actually generate a unique situation of rows and columns. • For example, say SW1 is pressed. This would form a path between Row1 and Column1. No other row and column would have a path.
  • 7. Principle of operation • Connect all rows to VDD through pull-up resistors. This means anytime you read the logic level across rows, it would be ‘1111’. • Connect Column 1 is at Logic 0(Ground), column 2 to VDD , column 3 to VDD and column 4 to VDD • If the user presses switch SW1, only row 1 will be connected to Column 1 and it would be grounded. The other three rows would be at 5V. The row information would be read 0111. • Instead if the user presses, SW9, only Row3 would be grounded and remaining rows be at VDD; row information would be read as 1101. • If you have information about status of all the rows and column, you have enough information to deduce or calculate, which switch has been pressed.
  • 8. Principle of operation • Note that, The rows and columns are just a convention and are absolutely interchangeable. This would necessarily mean that rows can behave as columns and columns can behave as rows. • Grounding column 1, connecting the other three columns to VDD and then reading row information would help you detect if any of the switches in Column1 has been pressed. • Extending the logic, to detect a switch press in Column2, you would have to ground Column2 and connect the other columns to VDD. Reading the row information would help you detect if SW2,SW6,SW10 or SW14 was pressed and so on • Lets build the general algorithm based on this information.
  • 9. • Connect the 4X4 matrix keypad to the 8 pins of the microcontroller or arduino or FPGA • As said earlier, since the rows and columns are interchangeable, you may vary the pattern you apply on columns and read the row information. Or you may vary the row information and read the columns. Principle of operation
  • 10. • If no switch is pressed, the rows would read 1111. • Apply the pattern 0111 to the columns and read all the rows. • The pattern 0111 on rows indicates SW1 is pressed. Pattern 1011 indicates SW4 is pressed. Pattern 1101 indicates Sw7 is pressed. Pattern 1110 indicates Sw* is pressed • Next apply the pattern 1011 to the columns and read all rows, to detect if a switch has been pressed in column2. • Similarly, apply the pattern 1101 to the columns and read all rows, to detect if a switch has been pressed in column3 • Similarly, apply the pattern 1110 to the columns and read all rows, to detect if a switch has been pressed in column4 • Repeat the above steps at a very fast rate, so that none of the key press goes undetected.
  • 11. Summarizing, • It is the function of the microcontroller to scan the keyboard continuously to detect and identify the key pressed • To detect a pressed key, the microcontroller grounds all columns, successively, by providing 0 and then it reads the rows • If the data read from rows is 1111, no key has been pressed and the process continues till key press is detected • If one of the row bits has a zero, this means that a key press has occurred • After detecting a key press, microcontroller will go through the process of identifying the key Principle of operation
  • 12. Summarizing, • Starting with the Column 1, the microcontroller grounds it by providing a low to Column C0 only  It reads all the rows.  If the data read is all 1s, no key in that row is activated and the process is moved to the next column • It grounds the next column, reads all the rows and checks for any zero • This process continues until the column in which key is pressed is identified  After identification of the column in which the key has been pressed, Find out which row the pressed key belongs to Principle of operation
  • 13. ORG 00H MOV DPTR, #LUT // The 7-segment codes of switch press detected are stored in Code memory MOV P0, #00000000B // initializes P0 as output port; 7-segment is connected to Port 0 ;------------CONNECTIONS------------------ ;P1.0 = Col 0, P1.1 = Col 1, P1.2 = Col 2, P1.3 = Col 3, ;P1.4 = Row 0, P1.5 =Row 1 P1.6 = Row 2, P1.7 = Row 3, BACK: CLR P1.0 // makes Column 0 low,; col 1, col2 and col3 = 1 JB P1.4,NEXT1 // checks whether Row 0 is low and jumps to NEXT1 if not low MOV A,#1D // Row0 =0 when Col 0 =0,indicates that SW1 has been pressed. Display 1 ACALL DISPLAY // calls DISPLAY subroutine NEXT1:JB P1.5,NEXT2 // checks whether Row 1 is low. Row 1 =0 indicates SW2 has been pressed. MOV A,#2D // Display 2 ACALL DISPLAY NEXT2:JB P1.6,NEXT3// Check whether Row2 is low MOV A,#3D //Display 3 ACALL DISPLAY NEXT3:JB P1.7,NEXT4//Check if Row 3 is low MOV A,#10 D //Display A ACALL DISPLAY ; This completed one set of Row checking With Col0 =0. Next make Col0 =1 and col1=0, Col2 =1 and col3=1, as earlier 1 4 7 D 2 5 8 E 3 6 9 F A B C 0 P1.0 P1.1 P1.2 P1.3 P1.4 P1.5 P1.6 P1.7 Each keypad would have same internal connections, But the numbers displayed on top might vary. This code will work only for the keypad display shown
  • 14. ; column information = 1011, read rows NEXT4:SETB P1.0 CLR P1.1 JB P1.4,NEXT5 MOV A,#4D ACALL DISPLAY NEXT5:JB P1.5,NEXT6 MOV A,#5D ACALL DISPLAY NEXT6:JB P1.6,NEXT7 MOV A,#6D ACALL DISPLAY NEXT7:JB P1.7,NEXT8 MOV A,#11D ACALL DISPLAY ; column information = 1101, read rows NEXT8:SETB P1.1 CLR P1.2 JB P1.4,NEXT9 MOV A,#7D ACALL DISPLAY NEXT9:JB P1.5,NEXT10 MOV A,#8D ACALL DISPLAY NEXT10:JB P1.6,NEXT11 MOV A,#9D ACALL DISPLAY NEXT11:JB P1.7,NEXT12 MOV A,#12D ACALL DISPLAY 1 4 7 D 2 5 8 E 3 6 9 F A B C 0 P1.0 P1.1 P1.2 P1.3 P1.4 P1.5 P1.6 P1.7
  • 15. ; column information = 1110, read rows NEXT12:SETB P1.2 CLR P1.3 JB P1.4,NEXT13 MOV A,#13D ACALL DISPLAY NEXT13:JB P1.5,NEXT14 MOV A,#14D ACALL DISPLAY NEXT14:JB P1.6,NEXT15 MOV A,#15D ACALL DISPLAY NEXT15:JB P1.7,BACK MOV A,#0D ACALL DISPLAY LJMP BACK ;DPTR points to first location of LUT. Accumulator contains the offset value to be added. Fetch the byte containing the Seven segment code from LUT (in Code memory) and display DISPLAY: MOVC A,@A+DPTR // MOV P0,A // puts corresponding digit drive pattern into P0 RET
  • 16. LUT: // Look up table starts here DB 11111100B //0… abcdefgh DB 01100000B //1 DB 11011010B //2 DB 11110010B //3 DB 01100110B //4 DB 10110110B DB 10111110B DB 11100000B DB 11111110B DB 11110110B DB 11101110B DB 00111110B DB 10011110B DB 01111010B DB 10011110B DB 10011110B //F END