|
#include<reg51.h>
#define uint unsigned int
unsigned char code segdate[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
sbit ks=P3^7;
int delay;
sbit SMG1=P3^3;
sbit SMG2=P3^2;
int ren;
void xianshi(int a)
{
SMG1=0;
P0=segdate[a/10];
delay=50000;
while(delay--);
SMG1=1;
SMG2=0;
P0=segdate[a%10];
delay=50000;
while(delay--);
SMG2=1;
}
void main()
{
unsigned char i;
int time;
while(1)
{ if (ks!=1)
for(time=30;time>0;time--)
for (i=8;i>0;i--)
{
xianshi(time);
if(P1!=0xff)
{
switch(P1)
{
case 0xfe:ren=1; break;
case 0xfd:ren=2; break;
case 0xfb:ren=3; break;
case 0xf7:ren=4; break;
case 0xef:ren=5; break;
case 0xdf:ren=6; break;
case 0xbf:ren=7; break;
case 0x7f:ren=8; break;
}
while(ks)
xianshi(ren);
time=30;
}
}
}
}
|
-
-
抢答器.rar
24.31 KB, 下载次数: 29, 下载积分: 黑币 -5
八位抢答器
|