Back to the 2024 paper

Module 6: Applications

20247m

Demonstrate interfacing of a 4x4 (16-key) keyboard with 8051, with neat circuit diagram and display using 8051 Microcontroller.

Worked SolutionAI Assisted

4×4 Keypad Interfacing with 8051 + Display

Hardware: Rows R1-R4 → P1.0-P1.3 (output), Columns C1-C4 → P1.4-P1.7 (input with pull-ups) or via P2. Keypad matrix 4×4=16 keys (0-9,A-F or 1-9,* #). Supply decoupling, debounce capacitors.

Scanning Algorithm:

  1. Drive all rows high.
  2. Set one row low at a time, read columns. Column low = key pressed at (row, col).
  3. Debounce 20 ms delay, re-read.
  4. Compute key code = row*4+col, look up ASCII in table.
  5. Display on 7-seg/LCD at P0.

Program sketch (assembly):

SCAN: MOV P1,#0F0H ; rows outputs pull?
ROW_LOOP: MOV A,#0FEH ; row0 low
        MOV P1,A
        MOV A,P1
        ANL A,#0F0H
        CJNE A,#0F0H,FOUND
        ; next row 0FDH etc
FOUND: ; compute
        MOV DPTR,#KEYMAP
        MOVC A,@A+DPTR
        MOV P2,A ; display
        ACALL DEBOUNCE

Display: Send decoded hex to LCD via P0 data + P2 control (RS,RW,EN) or to 7-seg via P0 segments + P2 digit select as in Q38. Multiplex display continuously.
Circuit: P1.0-3 via 470Ω to row lines, P1.4-7 via 10k pull-up to Vcc + column lines, optional 74C922 encoder alternative.

Similar questions

Budget AppAndroid App

Pocketly on Android

Log daily food, travel, and hostel expenses instantly. Set monthly spending limits and see where your money goes without complex spreadsheets.