#include<reg52.h>
sbit WEI = P1^6;
sbit DU = P1^7;
unsigned char code Disp_Tab[10] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; //段选
#define uchar unsigned char // 8bit, 0 ~ 255
#define uint unsigned int // 16bit, 0 ~ 65,535
void delayms(uint m) // 11.0592MHz 晶振ms延时,偏差小于1%
{
uint i, j;
for(i=m; i>0; i--)
for(j=114; j>0; j--);
}
void main()
{
unsigned char i = 0;
WEI = 1;
P0 = 0X7f;
WEI = 0;
DU = 1;
while(1)
{
for(i = 0; i < 10; i++) //循环10次
{
P0 = Disp_Tab[i];
delayms(500);
}
}
} |