| ??? 08/21/08 18:38 Read: times |
#157643 - code with comment Responding to: ???'s previous message |
#include<port.h>
#include"var_extern.h"
#include<intrins.h>
//p1=row
//p2=col
bdata unsigned char row_no,col_no;
sbit col_no0=col_no^0;
bit debounce=1;
void delay(unsigned int itime)
{
int i,j;
for(i=0;i<1275;i++)
{
for(j=0;j<itime;j++){}
}
}
//this function for checking which column is low
void col_check()
{
unsigned char i;
for(i=0;i<8;i++)
{
if(col_no0==0)
{
break;
}
col_no=col_no>>1;
}
col_no=i;
}
//this function for scaning keypad
unsigned char key_scan()
{
unsigned char temp,i,key=100;
col=0xff; //make colmn high
row=0x00; //make row low
while(col==0xff) //loop untile any column will be low(means untill any key is pressed)
{
}
temp=col;//value of col is stored for debounce check
delay(50);//debounce delay
while(col==0xff) //loop untile any column will be low(means untill any key is pressed)
{
}
if(temp!=col)//if key is same then this row and column will find
{
debounce=0;
key=100;
ACK=0;
return key;
}
else
{
while(col==0xff)// this routine for debounce check
{
}
temp=col;
delay(1);
while(col==0xff)
{
}
if(temp!=col)
{
debounce=0;
key=100;
return key;
}else
{
temp=0xfe; //make first row will low
for(i=0;i<8;i++)
{
row=_crol_(temp,i); //shift row by value of i
if(col!=0xff) //check any column is low or not
{ //if yes then read value of column port
col_no=col;
col_check(); //check which column is being low
key=key_matrix[i][col_no]; //put value of row and column in matrix and receive key
col=0xff;
row=0x00;
while(col!=0xff)
{
}
return key;
}
}
}
}
}
void keypad_init()
{
col=0xff;
row=0x00;
} |
| Topic | Author | Date |
| problem in 8x8 keypad | 01/01/70 00:00 | |
| I see ... | 01/01/70 00:00 | |
| this code with correction | 01/01/70 00:00 | |
| Try the Insert Code button. | 01/01/70 00:00 | |
| code with comment | 01/01/70 00:00 | |
| Lots of things to look into | 01/01/70 00:00 | |
| reply | 01/01/70 00:00 | |
| One way to debounce | 01/01/70 00:00 | |
| One Suggestion | 01/01/70 00:00 | |
| the easy way to do keypads | 01/01/70 00:00 | |
| indent, indent, indent | 01/01/70 00:00 | |
| problem in keypad | 01/01/70 00:00 | |
| Where is the code? | 01/01/70 00:00 | |
| code of 8x8 keypad | 01/01/70 00:00 | |
Simplify and think about debounce | 01/01/70 00:00 |



