اهلا بك

الكاتب

مرحبا بكم

البحث فى المدونه

اشترك ليصلك كل جديد

احصل على كل جديد فى عالم التدوين لحظه بلحظه اشترك الان

الأربعاء، 25 فبراير 2015

Interfacing 4×4 keypad with LCD using 8051 microcontroller

Project Detail:

In this project we use AT 89c51 microcontroller and interface 4×4 keypad at port 0 and LCD at port 2.
From this Proteous simulation circuit diagram we can see that four resistors R1,R2,R3,R4 are connected in P0.0,P0.1,P0.2,P0.3. These resistors are work as a pull-up resistor. Because we know for input/output operation of port0 of 8051 microcontroller need pull-up resistor. For more details regarding ports in 8051 read my previous post “Ports in 9051 microcontroller”.
Here you see the complete embedded C code written in Mikroc for 8051 about this project “Interfacing 4×4 keypad with LCD using 8051 microcontroller”
Embedded C Code
// Name : Interfacing 4×4 keypad with LCD using 8051 microcontroller
//  soufian soltan
// Date : 11-02-15
// Website : http://www.louhla.tk/
unsigned short kp;
// Keypad module connections
char keypadPort at P0;
// End Keypad module connections// Lcd module connections
sbit LCD_RS at P2_0_bit;
sbit LCD_EN at P2_1_bit;
sbit LCD_D4 at P2_2_bit;
sbit LCD_D5 at P2_3_bit;
sbit LCD_D6 at P2_4_bit;
sbit LCD_D7 at P2_5_bit;
// End Lcd module connections
void main() {
cnt = 0; // Reset counter
Keypad_Init(); // Initialize Keypad
Lcd_Init(); // Initialize Lcd
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1, 1, “Key :”); // Write message text on Lcd
Lcd_Out(2, 1, “Times:”);
do {
kp = 0; // Reset key code variable
// Wait for key to be pressed and released
do
// kp = Keypad_Key_Press(); // Store key code in kp variable
kp = Keypad_Key_Click(); // Store key code in kp variable
while (!kp);
// Prepare value for output, transform key to it’s ASCII value
switch (kp) {
//case 10: kp = 42; break; // ‘*’ // Uncomment this block for keypad4x3
//case 11: kp = 48; break; // ‘0’
//case 12: kp = 35; break; // ‘#’
//default: kp += 48;
case 1: kp = 55; break; // 1 // Uncomment this block for keypad4x4
case 2: kp = 56; break; // 2
case 3: kp = 57; break; // 3
case 4: kp = 65; break; // A
case 5: kp = 52; break; // 4
case 6: kp = 53; break; // 5
case 7: kp = 54; break; // 6
case 8: kp = 66; break; // B
case 9: kp = 49; break; // 7
case 10: kp = 50; break; // 8
case 11: kp = 51; break; // 9
case 12: kp = 67; break; // C
case 13: kp = 42; break; // *
case 14: kp = 48; break; // 0
case 15: kp = 35; break; // #
case 16: kp = 68; break; // D
}
Lcd_chr(2, 10, kp); // Display counter value on Lcd
} while (1);
}

التعليقات
0 التعليقات

0 التعليقات:

إضغط هنا لإضافة تعليق

إرسال تعليق

Blogger Widgets