c语言设计:22路流水灯,要求花样越多越好。用c51单片机的P0.P1.P2口。

如题所述

#include<reg52.h>
unsigned char code DM[]={0x00,0xff,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0xfe,0xfc,
0xf8,0xf0,0x0f,0xe0,0xc0,0x80,0x7e,0xbd,0xdb,0xe7};

void delay(unsigned int a)
{
while(a--);
}
void main()
{
unsigned char i;
for(i=0;i<21;i++)
{
P1=DM[i];
delay(55535);
}
}

这是八路得的,你看着就会做了追问

感谢你的回答!22路能不能用查表法写啊?能举个例子么?

追答

最好写个函数来实现

温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-07-26
花样只不过是送的不同值而已,象这类的组合,任意要多少是多的呀