[SOLVED] Need Help on designing 4x3 matrix ALPHABETICAL KEYPAD using 8051

Status
Not open for further replies.

MANO.5

Member level 1
Joined
Mar 15, 2013
Messages
36
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Visit site
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

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:

What problem you are facing?

Hai venkatesh,
thank you for your reply..what i am trying was after getting pressed key value i add one more function set_key(c,i) in set_key function c was key value and i was number of times key pressed .In set key function using switch case key value is displayed.

The modified program was
Code:
#include<reg52.h> //including sfr registers for ports of the controller


//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]);
	}
	
}

 void set_key(c,i)
{
switch(c)
{
  case 1:
   {
    switch(i)
    {
     case 1:{
	 lcd_command(0x80);	  
       lcd_data('a');
       Delay(50);       
       break; }

     case 2:{
	 lcd_command(0x80);	  
       lcd_data('b');
       Delay(50);     
       break;       }

     case 3: {
	 lcd_command(0x80);	  
       lcd_data('c');
       Delay(50);       
       break; }
     }
   }
}
}

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++;
	  set_key(c,i);
       /*lcd_command(0x88);	
     lcd_data(c);
     lcd_command(0xC8);
       lcd_data(i+48);
      Delay(100);	 */
	  if(i==4)
	  i=0;
      while(!(c = Read_Keypad()));
    }
    i=0;
   }
}

The program compiled without any error .But when simulating in proteus it didn't give anything.
 

Its a very easy project don worry. clear your main and check whether your LCD works fine or not ?
After making your LCD work there is nothing in the keyboard side. now lot of mistakes in the code.
So try to display some "hi" in lcd without keypad.
Also post your proteus project and hex file when you come next time.
 


Hai venkadesh,
there is no problem with lcd.it works fine.
hex file
Code:
  :1001FF00E4FEEEC39F5011E4FDFC0DBD00010CBCED
:08020F0004F8BDFBF50E80EAC6
:0102170022C4
:100218008F90D2A2C2A0C2A17F011201FFC2A22266
:100228008F90D2A2D2A0C2A17F011201FFC2A22246
:1001DC007F381202187F051201FF7F0F1202187F61
:1001EC000E1202187F051201FF7F011202187F0503
:0301FC000201FFFE
:0601B5008B088A09890A8B
:1001BB00E4F50BAB08AA09A90AAF0BEF3395E08F57
:1001CB0082F583120188FF6007120228050B80E37A
:0101DB002201
:10014C00EE7038EF147034AE04AF05EC702DEF2464
:10015C00FE6010146016240270217F801202187F3A
:10016C006180107F801202187F6280077F801202EC
:0C017C00187F631202287F321201FF225C
:10000300D2B4D2B5D2B6D2B7C2B0D2B1D2B2D2B3D1
:1000130020B40B7F641201FF30B4FD7F312220B581
:100023000B7F641201FF30B5FD7F322220B60B7FB8
:10003300641201FF30B6FD7F332220B70B7F6412B9
:1000430001FF30B7FD7F3422D2B0C2B1D2B2D2B3F6
:1000530020B40B7F641201FF30B4FD7F352220B53D
:100063000B7F641201FF30B5FD7F362220B60B7F74
:10007300641201FF30B6FD7F372220B70B7F641275
:1000830001FF30B7FD7F3822D2B0D2B1C2B2D2B3B2
:1000930020B40B7F641201FF30B4FD7F392220B5F9
:1000A3000B7F641201FF30B5FD7F302220B60B7F3A
:1000B300641201FF30B6FD7F3D2220B70B7F64122F
:1000C30001FF30B7FD7F2D22D2B0D2B1D2B2C2B37D
:1000D30020B40B7F641201FF30B4FD7F432220B5AF
:1000E3000B7F641201FF30B5FD7F302220B60B7FFA
:1000F300641201FF30B6FD7F3D2220B70B7F6412EF
:0B01030001FF30B7FD7F2B227F0022A0
:10010E00E4FBFA1201DC120003A907E960F8890C7E
:10011E00E50C6970240BBB00010AE9FF3395E0FE84
:10012E00AD03AC0212014CEB64044A7002FAFB12EE
:0E013E000003A907EF70D980F6E4FAFB80C831
:03000000020238C1
:0C023800787FE4F6D8FD75810C02010E01
:10018800BB010CE58229F582E5833AF583E022502C
:1001980006E92582F8E622BBFE06E92582F8E22276
:0D01A800E58229F582E5833AF583E4932290
:00000001FF
i can't upload proteus design ,the ploader says it was invalid file...........
 

Try this code, compress and post the project files.


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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#include<reg52.h> //including sfr registers for ports of the controller
 
//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);  
void lcd_command(unsigned char);   //LCD command funtion
void lcd_data(unsigned char);  //LCD data function 
void lcd_ini(void);               
void lcd_string(unsigned char *);    //LCD string function 
void set_key(unsigned int,unsigned int,unsigned int);
char Read_Keypad(void);
 
void main()
{
   unsigned int c = 0, p = 0, pos = 0, i = 0;
 
   lcd_ini();
   
  while(1)
  {
    p = c;
    
    while(!(c = Read_Keypad())); 
    
    if(p == c)
    {
      set_key(c,i,pos);
      
      if(++i >= 3)
      i=0;
    }
    else
    {
    i = 0;
    pos++;
    }
 
   }
}
 
void set_key(unsigned int c,unsigned int i, unsigned int pos)
{
    lcd_command(0x80 + pos);      
    lcd_data('a' + c*3 + i );
    Delay(50);       
}
 
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);
    
}
 
 
void lcd_string(unsigned char *disp)     //LCD string function 
{
    char x;
    for(x=0;disp[x]!=0;x++)
    {
        lcd_data(disp[x]);
    }
    
}
 
 
char Read_Keypad(void)
{
 
  C1 = 1;  C2 = 1;  C3 = 1;  C4 = 1;
  R1 = 0;  R2 = 0;  R3 = 0;  R4 = 0;
  if( C1 && C2 && C3 && C4 )
  return 0;
  
  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 10;}
  if(C3==0){Delay(100);while(C3==0);return 11;}
  if(C4==0){Delay(100);while(C4==0);return 12;}
  R1=1;
  R2=1;
  R3=1;
  R4=0;
  if(C1==0){Delay(100);while(C1==0);return 13;}
  if(C2==0){Delay(100);while(C2==0);return 14;}
  if(C3==0){Delay(100);while(C3==0);return 15;}
  if(C4==0){Delay(100);while(C4==0);return 16;}
  return 0;
}

 
Reactions: MANO.5

    MANO.5

    Points: 2
    Helpful Answer Positive Rating
Hai Venkadesh,
Thank you so much.Your code is working.I modify the code by adding EEPROM and forward,backspace key .I upload the protes design,HEX code. back space key is not working properly. please help to solve this problem also....
 

Attachments

  • key pad.zip
    21.5 KB · Views: 91

Hi

in while make these change

Remember you cant press the same key consecutively in old code for that you need a timing mechanism.

I added timer in following code


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
while(1)
  {
    p = c;    
 
    time = 5000000;
 
    while(!(c = Read_Keypad()) &&  time--); 
 
    if (time == 0)
    pos++;
    
    if(p == c && c != 14)
    {
     set_key(c,i,pos);
      
      if(++i >= 3)
      i=0;
    }
    else if(c == 14)
    {
    pos--;
    set_key(c,i,pos);
    i = 0;
    }
    else
    {
    i = 0;
    pos++;
    }
}


declare time as unsigned long

you can change the value for going to next char
 

Small change

Code C - [expand]
1
2
3
4
5
6
else if(c == 14)
    {
    set_key(c,i,pos);
    pos--;
    i = 0;
    }

 

Small change

Code C - [expand]
1
2
3
4
5
6
else if(c == 14)
    {
    set_key(c,i,pos);
    pos--;
    i = 0;
    }


Hai Venkatesh,
Thank you for your help.it was working now.........................
 

Attachments

  • key.zip
    20.4 KB · Views: 92

Hai venkatesh,
There is small problem can't type like 'baby'.need something time counter .If same key is pressed within 10 seconds and if not increase pos value .Please some help............
 

reduce the value of time variable in #9. post the hex file, i can also have a try.

Hai
reduce the time value [time=5000000]; to [time=2];But no change.This is the hex file
Code:
:0F04DA00D2A3E4FFD2A4C2A40FEFC3940A40F54B
:0104E90022F0
:09051600D2A3D2A4C2A3C2A42204
:09051F00C2A4C2A3D2A4D2A322FB
:1003EF00AB07AA06C2D71205167FA0120404AF02EC
:0503FF00120404AF032D
:10040400E4FEFDEEC313FE70027E80EE5F6004D254
:10041400D78002C2D792A3D2A4C2A40DBD08E4D24D
:07042400A3D2A4A2A3C2A40D
:01042B0022AE
:10045300E4FFD2A3FEC2D7EF25E0FFD2A4A2A3C23A
:10046300A430D7010F0EC3EE6480948840E7D2A373
:04047300D2A4C2A4A9
:010477002262
:0404B4008C1E8D1FEE
:1004B8001203EFAF1F12040412051F7F0D02049BE5
:1004C8001203EF1205167FA1120404120453120539
:0104D8001F04
:0104D9002200
:10000300E4F508F509F50AF50B74FFF50CF50DE4B5
:10001300F50EF50FF510F511751502F514F513F539
:10002300121204781204DA85080A85090B12016694
:10003300EF3395E0F5088F094F700D781274FF12B6
:1000430003D1EC4D4E4F70E5E50B65097004E50AED
:100053006508704DE509640E45086045E509640FC0
:100063004508603DD3E50D940FE50C9400E50D4084
:100073001024F0F511E50C34FFF510E51124C080D0
:10008300022480FF1204EA120288050FE50F7002B2
:10009300050EC39403E50E940050030201450201CB
:1000A30010E509640E45087030E50D150D70021555
:1000B3000CD3E50D940FE50C9400E50D401024F0EE
:1000C300F511E50C34FFF510E51124C080022480FE
:1000D300FF1204EA1202888034E509640F450870B0
:1000E30033050DE50D7002050CD3940FE50C940058
:1000F300E50D401024F0F511E50C34FFF510E51182
:1001030024C080022480FF1204EA120288E4F50E60
:10011300F50F802EE4F50EF50F050DE50D700205C4
:100123000CD3940FE50C9400E50D401024F0F51169
:10013300E50C34FFF510E51124C080022480FF1282
:1001430004EAE4FFFEFDFCAB15AA14A913A812C32D
:100153001203BE600302002A050DE50D7002050CB3
:0301630002002A6D
:0C028800AB0DAA0CAD0FAC0EAF09AE0818
:0C0294008E168F178C188D198A1A8B1B80
:1002A000E4F51CF51DD3E5179409E51694004017F5
:1002B000E517940DE5169400500D7C007D031203A4
:1002C000ACEF2412020358E517640D4516702BE5B8
:1002D0001945187007F51C751D398068E51964010A
:1002E00045187007F51C751D2E8059E519640245E7
:1002F000187051F51C751D2D804AE517640E4516C2
:1003000070028008E517640F45167007F51C751D0F
:10031000208031E51764104516702FE519451870D7
:1003200007F51C751D2D801CE51964014518700723
:10033000F51C751D3D800DE519640245187005F525
:100340001C751D23AD1DAC1C801FAE16AF177C00A5
:100350007D031203ACEF243EFFE43EFEE5192FF5CA
:100360001DE5183EF51CAD1DFCAF1BAE1A1204B402
:0F037000AF1BAE1A1204C81204FA7F0A02049BD4
:10049B00E4FEEEC39F5011E4FDFC0DBD00010CBC4E
:0804AB0004F8BDFBF50E80EA28
:0104B3002226
:1004EA008F90D2A2C2A0C2A17F0112049BC2A222F3
:1004FA008F90D2A2D2A0C2A17F0112049BC2A222D3
:100478007F381204EA7F0512049B7F0F1204EA7F7B
:100488000E1204EA7F0512049B7F011204EA7F051D
:0304980002049BC0
:06042C008B208A218922C9
:10043200E4F523AB20AA21A922AF23EF3395E08F65
:1004420082F58312037FFF60071204FA052380E31B
:010452002287
:10016600D2B4D2B5D2B6D2B7C2B0C2B1C2B2C2B39D
:1001760030B40C30B50930B60630B7037F0022C262
:10018600B0D2B1D2B2D2B320B40B7F0A12049B30E4
:10019600B4FD7F012220B50B7F0A12049B30B5FD0A
:1001A6007F022220B60B7F0A12049B30B6FD7F0326
:1001B6002220B70B7F0A12049B30B7FD7F0422D2A0
:1001C600B0C2B1D2B2D2B320B40B7F0A12049B30B4
:1001D600B4FD7F052220B50B7F0A12049B30B5FDC6
:1001E6007F062220B60B7F0A12049B30B6FD7F07DE
:1001F6002220B70B7F0A12049B30B7FD7F0822D25C
:10020600B0D2B1C2B2D2B320B40B7F0A12049B3073
:10021600B4FD7F092220B50B7F0A12049B30B5FD81
:100226007F0A2220B60B7F0A12049B30B6FD7F0B95
:100236002220B70B7F0A12049B30B7FD7F0C22D217
:10024600B0D2B1D2B2C2B320B40B7F0A12049B3033
:10025600B4FD7F0D2220B50B7F0A12049B30B5FD3D
:100266007F0E2220B60B7F0A12049B30B6FD7F0F4D
:100276002220B70B7F0A12049B30B7FD7F10227F26
:02028600002254
:0300000002050AEC
:0C050A00787FE4F6D8FD75812302000321
:10037F00BB010CE58229F582E5833AF583E0225033
:10038F0006E92582F8E622BBFE06E92582F8E2227D
:0D039F00E58229F582E5833AF583E4932297
:1003AC00EF8DF0A4A8F0CF8CF0A428CE8DF0A42E65
:0203BC00FE221F
:1003BE00EB9FF5F0EA9E42F0E99D42F0E89C45F095
:0103CE00220C
:1003CF007401FF3395E0FEFDFC080808E6CF2FF619
:1003DF0018E6CE3EF618E6CD3DF618E6CC3CF622F2
:00000001FF
 
Last edited:

Hi make change,
instead of this

Code C - [expand]
1
while(!(c = Read_Keypad()) &&  time--);


code this

Code C - [expand]
1
while( ( !(c = Read_Keypad()) ) &&  time--);


and now try editing the time value..
 

Hai.
this code is working
Code:
while(1)
  {
 
   p = c;   
   time=15000;
    //while(!(c = Read_Keypad()) &&  time--); 		 	 
    while( ( !(c = Read_Keypad()) ) &&  time--);
	if (time == 0)	
	 pos++;	
    if(p == c && c != 14 && c != 15)
    {
	  	if(pos>15)
		{
		j=pos-16;
		 
		 lcd_command(0xC0+j);  
		}
		else
		{
	 	lcd_command(0x80+pos); 
		}
        set_key(c,i,pos);
		  if(++i >= 3)
        i=0; 
    }
    else if(c == 14)
    {
    pos--;
	if(pos>15)
		{
		 j=pos-16;
		 lcd_command(0xC0+j);  
		}
		else
		{
	 	lcd_command(0x80+pos); 
		}
    set_key(c,i,pos);
    i = 0;
    }
	else if(c == 15)
    {
    pos++;
	if(pos>15)
		{
		 j=pos-16;
		 lcd_command(0xC0+j);  
		}
		else
		{
	 	lcd_command(0x80+pos); 
		}
    set_key(c,i,pos);
    i = 0;
    }
    else
    {
    i = 0;
    pos++;
	if(pos>15)
		{
		 j=pos-16;
		 lcd_command(0xC0+j);  
		}
		else
		{
	 	lcd_command(0x80+pos); 
		}
    }
	}
but if we need to type "baby" the output is "b a by". BECAUSE pos value is incremented 2 times ... In first at //if (time == 0)
pos++ and second is
Code:
 else
    {
    i = 0;
    pos++;
	if(pos>15)
		{
		 j=pos-16;
		 lcd_command(0xC0+j);  
		}
		else
		{
	 	lcd_command(0x80+pos); 
		}
    }
 

Hi,
No change in output. it will show like "b a b y" and if time=0 before pressing any other key it will show some random values.... This is the proteus design and hex file....
 

Attachments

  • key.zip
    22 KB · Views: 91

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…