Alphanumeric keyboard with 8051 microcontroller(89c51,89c52)
Roberto Magalhães
This tutorial teaches how an alphanumeric keyboard can be designed with 89c51 microcontroller, 16×2 LCD and 4×4 keyboard? The main crux of the project is in the project code. The 4x4 keyboard is just a set of buttons, arranged in Coulomb and row orders. To use its buttons we have to write a software routine for each keyboard button in our main code. The buttons performed what we programmed in the code. So we can get any function from the buttons. Normally we map them as the keyboard keys printed on the physical keyboard. In this tutorial we will map the keyboard with various numbers and characters. A single button can input multiple numbers or characters mapped to it.
The alphanumeric keyboard layout that I will program is below. In the first 2 lines, each button receives 3 characters and 1 number. The next row buttons are mapped to special characters and each button can input 3 alphabets. The last line is assigned with mathematical operators and up to 2 mathematical operators can be entered by 1 button.
Alphanumeric keyboard with microcontroller key layout
Alphanumeric Keyboard Hardware Requirements
4×4 Keyboard
LCD 16×2
Um 80s51 0r 89c51
Oscillator to provide the required clock frequency to the microcontroller.
A variable potentiometer/resistor to set the contrast of the 16×2 LCD.
Alphanumeric Keypad Circuit Diagram
The 4×4 keyboard is connected to Port 1 of the 8051 microcontroller (89c51,89c52). The 16×2 LCD is connected to port 2 of the 89c51 microcontroller. The control pins of the 16×2 LCD controller are connected to port 3 of the 8051 microcontroller. All other connections are power connections for the 8051 microcontroller. Apply 5 volts to pins 31 and 40 of the 8051 microcontroller. 0592 MHz between pins 18 and 19 of the 8051 controller in parallel to two 33 PF capacitors. Connect your reset circuit to pin #9 of 89c51.
8051 Alphanumeric Keyboard Circuit Diagram
Alphanumeric keyboard code 8051
First of all, never forget to include #includeheader file in every 8051 project because this is the file that contains all the linking and debugging code needed by the keil compiler. Below are some functions and their definitions with operating principles.
empty keyboard Identification of pressed buttons.
empty cmd (c character) Sending commands to the lcd.
empty delay (int num) Required delay function.
void lcdinit Initializing the LCD and its driver chipset.
void lcddata(char c) Sending data to lcd.
The statement data port sfr=0xA0 is accessing port 2 of 8051 with your sfr. Then the Coulomb and line pins are set at Port-1 of 89c51. The 16×2 LCD rw and en pins (to learn more about rw and en click the link) are defined on port 3, pin numbers 5 and 6. Next comes my main function which starts first with the lcdinit function. This initializes the 16x2 lcd and its driver chipset. Ten I am printing the string “ PLEASE ENTER YOUR NAME ” on my LCD after some time this message disappears and you can enter your name using 4×4 keyboard.
Download the project files and code (C++, HEX). The code is written in C++ language and keil u-vision4 is used to compile the code and generate Hex code. Please give us your feedback on the project. If you have any questions, please write them below.
Watch the project video below
Alphanumeric keyboard with code 8051(89c51,89c52 )