#include <stc15f2k60s2.h>
#include <intrins.h>
#define LED P2
sbit k1=P1^6;
sbit L1=P4^4;
unsigned char code table[]={0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
unsigned char a,b;
void Delay100ms() //@11.0592MHz
{
unsigned char i, j, k;
_nop_();
_nop_();
i = 5;
j = 52;
k = 195;
do
{
do
{
while (--k);
} while (--j);
} while (--i);
}
void Delay100us() //@11.0592MHz
{
unsigned char i, j;
_nop_();
_nop_();
i = 2;
j = 15;
do
{
while (--j);
} while (--i);
}
void main()
{
L1=0;
while(1)
{
if(k1==0)
{
Delay100us();
}
if(k1==0)
{
LED=table[a];
a++;
Delay100ms();
if(a==16)
{
a=0;
}
while((k1==0)&&(b<50))
{
Delay100ms();
b++;
}
b=0;
}
}
}
|