Description: #include<reg51.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit SDA=P1^0
sbit CLK=P1^1
sbit P1_2=P1^2
uchar checkKey[8] ={1,2,4,8,16,32,64,128}
code uchar Table[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}
void delay()
{
uint i
for(i=0 i<=500 i++)
}
void send(uchar a)
{
uchar i
for(i=0 i<8 i++)
{
if(_crol_(a,i)&0x80)
SDA=1
else
SDA=0
CLK=0
CLK=1
}
}
void xianshi(uchar a)
{
uchar coun
uchar com=0xbf
coun=a 10
P1=0xff
send(~Table[coun])
P1=com
delay()
P1=0xff
}
int main(void)
{
uint i
uchar keyValue
while(1)
{
send(0x00)
if(P1_2 == 0)
{
for(i = 0 i <8 i++)
{
send(~checkKey[i])
if(P1_2 == 0)
{
keyValue = i
xianshi(keyValue)
break
}
}
}
}
}
To Search:
File list (Check if you may need any files):
jpxs\jpxs.c
jpxs