8051 Interface – Keypad



Image Source

Keypad is a widely used input device with lot of applications such as telephone, computer, ATM, electronic lock etc. A keypad is used to take input from the user for further processing. Here a 4 by 3 matrix keypad consisting of switches arranged in rows and columns is interfaced to the microcontroller. A 16 by 2 LCD is also interfaced for displaying the output. The interfacing concept of keypad is very simple. Every number of keypad is assigned two unique parameters that are row and column (R, C). Hence every time a key is pressed the number is identifying by detecting the row and column numbers of keypad.

4×4 Keypad Internal Circuit Diagram

Image Source


Required Components

  • 4×4 Keypad or 3×4 Keypad (Here we will discuss both codes)
  • LCD Module (To print the Keys pressed)
  • 8051 Micro-controller


8051 Interface 4×3 Keypad Diagram

Image Source


8051 Interface 4×4 Keypad Connections


  • RS  –  P3.5
  • RW  – P3.6
  • EN  –  P3.7
  • Data Lines – P2


  • R1 – P1.0
  • R2 – P1.1
  • R3 – P1.2
  • R4 – P1.3
  • C1 – P1.4
  • C2 – P1.5
  • C3 – P1.6
  • C4 – P1.7


8051 Interface 4×4 Keypad C Code


8051 Keypad Interface Code Explanation

Initially all the rows are set to zero (‘0’) by the controller and columns are scanned to check if any key is pressed. In case of no key is pressed the output of all columns will be high (‘1’).

Image Source

Image Source




Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

if you have any queries call us +918300026060 or WhatsApp Dismiss


Your Cart

%d bloggers like this: