Keypad and Lcd interfaced with 8051 microcontroller – Project requirements
- 16×2 lcd
- 4×4,4×3 numericc keypad
- 8051(89c51,89c52) Microcontroller
- Power supply(5 volts)
- Crystal Oscillator(11.0592 MHz)
- Bread board (To build circuit)
- Potentiometer(Variable Resistor) To adjust Lcd contrast
4×3 Keypad, 16×2 Lcd interfaced with 89c51 microcontroller – Project code
Lcd keypad with 8051 microcontroller- Project code
Main() function executes first. The first four statements of main function initializes Port-1 as output, Port-3 as output, Port-2 upper nibble as input and lower nibble as output. Port-2 upper nibble(4 bits) are connected to 4×3 keypad rows and lower nibble is connected with coulombs of 4×3 numeric keypad. Since there are only three coulombs so pin(25 P2.4) of lower nibble is left void. Then lcdint() function is called to initialize the 16×2 lcd. After initializing the 16×2 next comes the while() loop. lcd The while loop then prints “KEYPAD WITH LCD” string on first line of 16×2 lcd. lcdcmd(0xC0) command jumps the control to second line. Now the for loop is running 16 times and calling the keypad() function 16 times. Actually i am using it to print 16 characters on the second line of 16×2 lcd. Whats going on in keypad() function is important.
Keypad key scanning function with 89c51 microcontroller code
Note: The the condition for checking rows and coulombs is placed in a while loop the while loop condition runs until c=’s’, and i am making c=’s’ when any key is pressed. Thus the control will stuck in to the while loop when no key is pressed.This logic is very important and you have to learn it very deeply. If you are interested.
Filed Under: 8051 Microcontroller, Microcontroller Projects