0% found this document useful (0 votes)
128 views4 pages

86409interfacing The Keyboard To 8051 Microcontroller

The document discusses interfacing a matrix keyboard to an 8051 microcontroller. It describes how the rows and columns of the keyboard are connected to ports on the 8051. When a key is pressed, it closes a row and column, causing a bit on the input port to go high. The program scans the rows and columns to determine which key was pressed by a counter. It rotates the input port bits until the carry flag sets, incrementing the counter each time, then displays the key number.

Uploaded by

mukasura
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
128 views4 pages

86409interfacing The Keyboard To 8051 Microcontroller

The document discusses interfacing a matrix keyboard to an 8051 microcontroller. It describes how the rows and columns of the keyboard are connected to ports on the 8051. When a key is pressed, it closes a row and column, causing a bit on the input port to go high. The program scans the rows and columns to determine which key was pressed by a counter. It rotates the input port bits until the carry flag sets, incrementing the counter each time, then displays the key number.

Uploaded by

mukasura
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

Interfacing the Keyboard to 8051 microcontroller

The key board here we are interfacing is a matrix keyboard. This key board is designed with a particular rows and columns. These rows and columns are connected to the microcontroller through its ports of the micro controller 8051. e normally use 8!8 matrix key board. "o only two ports of 8051 can be easily connected to the rows and columns of the key board. hen e#er a key is pressed$ a row and a column gets shorted through that pressed key and all the other keys are left open. hen a key is pressed only a bit in the port goes high. hich indicates microcontroller that the key is pressed. %y this high on the bit key in the corresponding column is identified. &nce we are sure that one of key in the key board is pressed next our aim is to identify that key. To do this we firstly check for particular row and then we check the corresponding column the key board. To check the row of the pressed key in the keyboard$ one of the row is made high by making one of bit in the output port of 8051 high. This is done until the row is found out. &nce we get the row next out 'ob is to find out the column of the pressed key. The column is detected by contents in the input ports with the help of a counter. The content of the input port is rotated with carry until the carry bit is set. The contents of the counter is then compared and displayed in the display. This display is designed using a se#en segment display and a %() to se#en segment decoder I( *++*. The %() e,ui#alent number of counter is sent through output part of 8051 displays the number of pressed key.

(ircuit diagram of INTERFACING KEY BOARD TO 8051. The programming algorithm$ program and the circuit diagram is as follows. -ere program is explained with comments .

Circuit diagram of INTERFACING KEY BOARD TO 8051. Keyboard is organi ed in a !a"ri# o$ ro%s and &o'(!ns as s)o%n in ")e $ig(re. T)e !i&ro&on"ro''er a&&esses bo") ro%s and &o'(!ns ")ro(g) ")e *or". 1. The 8051 has + I.& ports /0 to /0 each with 8 I.& pins$ /0.0 to /0.*$ /1.0 to /1.*$ /1.0 to /1.*$ /0.0 to /0.*. The one of the port /1 2it understood that /1 means /1.0 to /1.*3 as an I./ port for microcontroller 8051$ port /0 as an &./ port of microcontroller 8051 and port /1 is used for displaying the number of pressed key. 2. 4ake all rows of port /0 high so that it gi#es high signal when key is pressed. 3. 4. 5. "ee if any key is pressed by scanning the port /1 by checking all columns for non 5ero condition. If any key is pressed$ to identify which key is pressed make one row high at a time. Initiate a counter to hold the count so that each key is counted.

6.

(heck port /1 for non5ero condition. If any non5ero number is there in 6accumulator7$ start column scanning by following step 8. &therwise make next row high in port /1. 9dd a count of 08h to the counter to mo#e to the next row by repeating steps from step :.

7. 8. 9.

If any key pressed is found$ the 6accumulator7 content is rotated right through the carry until carry bit sets$ while doing this increment the count in the counter till carry is found.

10. 4o#e the content in the counter to display in data field or to memory location 11. To repeat the procedures go to step 1. Program to interfa e matri! "e#$oar% to mi ro ontro&&er 8051

Start of main program:


to check that whether any key is pressed start: rows of port p1 zero mov a,#0fh mov p1,a rows of port p1 high press: any key is pressed after making sure that any key is pressed mov a,#01h high at a time mov r4,a mov r ,#00h counter next: mov a,r4 ;initiating ;make one row mov a,p2 jz press ;making all ;check until mov a,#00h mov p1,a ;making all

mov p1,a row high at a time mov a,p2 from port ! jnz colscan the row jump to check mov a,r4 rl a check ne"t row mov r4,a mov a,r add a,#0#h counter $y 0# count mov r ,a sjmp next ne"t row after identifying the row to check the colomn following steps are followed

;making one ;taking input ;after getting column ;rotate left to

;increment ;jump to check

colscan% mov r&,#00h in% rrc a ;rotate right with carry until get the carry jc out ;jump on getting carry inc r ;increment one count jmp in out% mov a,r da a ;decimal adjust the contents of counter $efore display mov p2,a jmp start ne"t key' ;repeat for check

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy