#include<reg52.h>
#include<intrins.h>
#define uint unsigned int
#define uchar unsigned char
sbit wea=P2^2;
sbit web=P2^3;
sbit wec=P2^4;
uchar i;
uchar code duanma[]={0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
void delay(uint z);
void delay(uint z)
{
while(z--);
}
void main()
{
while(1)
{
P0=0xff;
wea=0;
web=0;
wec=0;
for(i=0;i<=15;i++)
{
P0=duanma[i];
delay(40000);
}
}
} 这是我修正过的,现在可以正常一位数码管,0~F循环显示,时间delay,里面的可以写数值,谢谢大家指点! |