MANO.5
Member level 1
- Joined
- Mar 15, 2013
- Messages
- 36
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,286
- Activity points
- 1,618
i want to design a ALPHABETICAL KEYPAD for one of my project that need to store some name on eeprom.When i was searching on web i didn't get anything.The following code is just numerical keypad ,it count and display how many times the key is pressed.I try to alter this code for ALPHABETICAL KEYPAD but i can't.please somebody help to solve this issue.
numerical keypad 4x3
numerical keypad 4x3
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 //LCD Module Connections sbit rs = P2^0; sbit rw = P2^1; sbit en = P2^2; #define dataport P1 // Data port for LCD //End LCD Module Connections //Keypad Connections sbit R1 = P3^0; sbit R2 = P3^1; sbit R3 = P3^2; sbit R4 = P3^3; sbit C1 = P3^4; sbit C2 = P3^5; sbit C3 = P3^6; sbit C4 = P3^7; //End Keypad Connections void Delay(unsigned char msdelay) { unsigned int j; unsigned char i; for(i=0;i<msdelay;i++) for(j=0;j<1275;j++); } void lcd_command(unsigned char comm) //LCD command funtion { dataport=comm; en=1; rs=0; rw=0; Delay(1); en=0; } void lcd_data(unsigned char disp) //LCD data function { dataport=disp; en=1; rs=1; rw=0; Delay(1); en=0; } void lcd_ini() { lcd_command(0x38); Delay(5); lcd_command(0x0F); lcd_command(0x0E); Delay(5); lcd_command(0x01); Delay(5); } lcd_string(unsigned char *disp) //LCD string function { char x; for(x=0;disp[x]!=0;x++) { lcd_data(disp[x]); } } char Read_Keypad() { C1=1; C2=1; C3=1; C4=1; R1=0; R2=1; R3=1; R4=1; if(C1==0){Delay(100);while(C1==0);return('1');} if(C2==0){Delay(100);while(C2==0);return '2';} if(C3==0){Delay(100);while(C3==0);return '3';} if(C4==0){Delay(100);while(C4==0);return '4';} R1=1; R2=0; R3=1; R4=1; if(C1==0){Delay(100);while(C1==0);return '5';} if(C2==0){Delay(100);while(C2==0);return '6';} if(C3==0){Delay(100);while(C3==0);return '7';} if(C4==0){Delay(100);while(C4==0);return '8';} R1=1; R2=1; R3=0; R4=1; if(C1==0){Delay(100);while(C1==0);return '9';} if(C2==0){Delay(100);while(C2==0);return '0';} if(C3==0){Delay(100);while(C3==0);return '=';} if(C4==0){Delay(100);while(C4==0);return '-';} R1=1; R2=1; R3=1; R4=0; if(C1==0){Delay(100);while(C1==0);return 'C';} if(C2==0){Delay(100);while(C2==0);return '0';} if(C3==0){Delay(100);while(C3==0);return '=';} if(C4==0){Delay(100);while(C4==0);return '+';} return 0; } void main() { int i=0; char c,p; lcd_ini(); while(1) { lcd_command(0x01); lcd_command(0x80); lcd_string("Key :"); lcd_command(0xc0); lcd_string("Times:"); while(!(c = Read_Keypad())); p=c; while(p==c) { i++; lcd_command(0x88); lcd_data(c); lcd_command(0xC8); lcd_data(i+48); Delay(100); while(!(c = Read_Keypad())); } i=0; } }
Last edited by a moderator: