interfacing keypad with 89c52

Status
Not open for further replies.

misha82

Member level 2
Joined
Jun 6, 2005
Messages
45
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,641
hi
can anybody give me an idea how to interface a keypad with 4 keys with a microcontroller 89c51?
thanx
 

Sooner or later you'll need more than 4.
Watch these slides:
**broken link removed**
 

i use 89s52 but the principle is same maybe is not the best variant but work !

while(1)
{
Sw_State = Switch_Get_Input(10);
Display_Switch_Update(Sw_State);
}
.....................................
char Switch_Get_Input(const unsigned char debounce_period)
{
char Return_value = 0x00;
if(Switch_Pin_1 == 0)
{
delay_ms(debounce_period);
if(Switch_Pin_1 == 0)
{
while(Switch_Pin_1 == 0);
Return_value = 0x01;
}
}
if(Switch_Pin_2 == 0)
{
delay_ms(debounce_period);
if(Switch_Pin_2 == 0)
{
while(Switch_Pin_2 == 0);
Return_value = 0x02;
}
}
if(Switch_Pin_3 == 0)
{
delay_ms(debounce_period);
if(Switch_Pin_3 == 0)
{
while(Switch_Pin_3 == 0);
Return_value = 0x03;
}
}
if(Switch_Pin_4 == 0)
{
delay_ms(debounce_period);
if(Switch_Pin_4 == 0)
{
while(Switch_Pin_4 == 0);
Return_value = 0x04;
}
}
return Return_value;
}
---------------------------------------------------------------
void Display_Switch_Update(const char SWITCH_STATUS)
{
switch (SWITCH_STATUS){
case 0x01 :
Some command;
break;
case 0x02 :
Some command;
break;
case 0x03 :
Some command;
break;
case 0x04 :
Some command;
break;
default:
Some command;
break;
}
}

..::SyRaX:..
 

HI All

Plz help me i m new in micro controller.i m using 89s51 mc and want to make a keypad lock using it. so plz help me out.


casamiro
 

simple way:

make variable enabled

and then :
if(enabled){
get_key();
}

if you wanna lock keys just make enabled = 0
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…