2019-07-15 08:59发布
chenwei6991627 发表于 2018-1-18 11:15 不能显示的话,先把显示调好啊
晓晓江南 发表于 2018-1-19 10:22 TempDate[5]=duanma[num/10]; TempDate[5]=duanma[num%10];
最多设置5个标签!
十位个位来回跳0
我也改了1,2一样的 求赐教
#define Dateport P2
#define unit unsigned int
#define uchar unsigned char
sbit weixuan=P3^1;
sbit duanxuan=P3^0;
uchar code duanma[10]={0x30,0xf9,0x52,0xd0,0x99,0x94,0x14,0xf1,0x10,0x90};
uchar code weima[8]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
uchar TempDate[1];
void delay(unit i);
void display(unit firstbit,unit num);
void main()
{
unit num;
while(1)
{
if(num==100)num=0;
TempDate[0]=duanma[num/10];
TempDate[1]=duanma[num%10];
num++;
display(1,2);
}
}
void delay(unit i)
{
while(i--);
}
void display(unit firstbit,unit num)
{
unit t;
for(t=0;t<num;t++)
{
Dateport=0;
duanxuan=1;
duanxuan=0;
Dateport=weima[t+firstbit];
weixuan=1;
weixuan=0;
Dateport=TempDate[t];
duanxuan=1;
duanxuan=0;
delay(1000);
}
}
有些变量不知何意,只能帮你到这了。
#define Dateport P2
#define unit unsigned int
#define uchar unsigned char
sbit weixuan=P3^1;
sbit duanxuan=P3^0;
uchar code duanma[10]={0x30,0xf9,0x52,0xd0,0x99,0x94,0x14,0xf1,0x10,0x90};
uchar code weima[8]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
uchar TempDate[1];
void delay(unit i);
void display(unit firstbit,unit num);
void main()
{
unit num;
while(1)
{
if(num==100)num=0;
TempDate[0]=duanma[num/10];
TempDate[1]=duanma[num%10];
num++;
display(1,2);
}
}
void delay(unit i)
{
while(i--);
}
void display(unit firstbit,unit num)
{
unit t;
for(t=0;t<num;t++)
{
Dateport=0;
duanxuan=1;
duanxuan=0;
Dateport=weima[t+firstbit];
weixuan=1;
weixuan=0;
Dateport=TempDate[t];
duanxuan=1;
duanxuan=0;
delay(1000);
}
}
有些变量不知何意,只能帮你到这了。
一周热门 更多>