Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

c programing for keypad 4x3 and lcd intefacing for 89C51

Status
Not open for further replies.

jannogale

Newbie level 4
Joined
Jul 29, 2010
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
UK
Activity points
1,331
i am final year student and my final project is about to write c programing for keypad 4x3 and lcd intefacing for 89C51 connecting rs232.
int main()
{
int col,key=0;



while(1)
{
P0=0x0e
col=&0x70;
switch (col)
{
case 0x60: key=1;
break;
case 0x50: key=2;
break;
case 0x30: key=3;
break;
}
//printf("\n key=%d;",key);


P0=0x0d
col=&0x70;
switch (col)

{
case 0x60: key=4;
break;
case 0x50: key=5;
break;
case 0x30: key=6;
break;
}

//printf("\n key=%d;",key);

P0=0x0b
col=&0x70;
switch (col)
{
case 0x60: key=7;
break;
case 0x50: key=8;
break;
case 0x30: key=9;
break;
}
P0=0x0b
col=&0x70;
switch (col)
{
case 0x60: key='*';
break;
case 0x50: key=0;
break;
case 0x30: key='
break;
}
my problem in this program is when i press the key bottom it does not shows me the number that i pressed. plez help me i need your help[/code]
 

my problem in this program is ...

your biggest problem in this program is that you don't comment. a good piece of code will necessarily have extensive comments to help you and its readers understand your thought process and help you fix your problems.
 

Dude give comments or else you can use use a encode and decode for keypad.. from the decoder output will come out as binary and you can connect it to a port and get the desired results
 

dude why did you commented out the actual parts that write to the serial port!!!!!!!!!!!

//printf("\n key=%d;",key);


also, it lacks of a serial init and serial io...

it's keil? ride? sdcc? anyway, check onto their documentation... there are many rs232 examples you should run prior using the serial port...


or...

you just posted an incomplete program?????
 

instead of

case 0x60: key=4;
break;

write down

case 0x60: key='4';
break;

replace at all key assignments,

if u want to display it on serial port u should pass its ascii value...
key = '4' will solve dat problem
 

Hello!

Beside the comments that indeed would be useful, you write twice the
same code at the end (P0 = 0x0b, etc…). At first it started with P0 = 0x0e,
then 0x0d, then 0x0b, so I guess the last one should be 0x07 instead of 0x0b.

And the last case: key = ' seems suspicious to me. Probably you wanted to
write key = '#';

Last thing. Somebody already told you, but let's put it in other words: you are
mixing integers and printable characters. Write all the keys between quotes,
or all the keys as integers, but don't mix.

Dora.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top