作者在 2017-04-11 09:11:10 发布以下内容
#include <reg52.h>
typedef unsigned int U16;
typedef unsigned char U8;
U8 num[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0X7F};
sbit LED1=P1^0;
sbit LED2=P1^1;
sbit LED3=P1^2;
sbit LED4=P1^3;
void TO_INIt()
{
U8 j=0,t=0,n=0;
TMOD=0x10;
TH1=0x3C;
TL1=0xB0;
TR1=1;
void refresh()
while(1)
{
if(1==TF1)
{
TF1=0;
TH1=0XFC;
TL1=0X18; 0.001S
n++;
}
if(20==n)
{
P0=num[j++];
n=0;
}
if(10==j)
j=0;
switch(t)
{
case 0:LED1=0;LED2=0;LED3=0;LED4=0;t++;break;
case 1:LED2=0;LED1=0;LED3=0;LED4=1;t++;break;
case 2:LED3=1;LED1=0;LED2=0;LED4=0;t++;break;
case 3:LED4=0;LED1=0;LED2=1;LED3=0;t=0;break;
default :break;
}
}
}
typedef unsigned int U16;
typedef unsigned char U8;
U8 num[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0X7F};
sbit LED1=P1^0;
sbit LED2=P1^1;
sbit LED3=P1^2;
sbit LED4=P1^3;
void TO_INIt()
{
U8 j=0,t=0,n=0;
TMOD=0x10;
TH1=0x3C;
TL1=0xB0;
TR1=1;
void refresh()
while(1)
{
if(1==TF1)
{
TF1=0;
TH1=0XFC;
TL1=0X18; 0.001S
n++;
}
if(20==n)
{
P0=num[j++];
n=0;
}
if(10==j)
j=0;
switch(t)
{
case 0:LED1=0;LED2=0;LED3=0;LED4=0;t++;break;
case 1:LED2=0;LED1=0;LED3=0;LED4=1;t++;break;
case 2:LED3=1;LED1=0;LED2=0;LED4=0;t++;break;
case 3:LED4=0;LED1=0;LED2=1;LED3=0;t=0;break;
default :break;
}
}
}