//花样流水灯
//显示步骤如下:
//数码管 LED(D1,D2......D7,D8),(1表示LED亮,0表示LED灭)
//0000 1111 1111 FF 花样一
//1111 0111 1110 7E
//2222 1011 1101 BD
//3333 1101 1011 DB
//4444 1110 0111 E7
//5555 1101 1011 DB
//6666 1011 1101 BD
//7777 0111 1110 7E
//8888 0011 1100 3C
//9999 0001 1000 18
//AAAA 0000 0000 00
//BBBB 0001 1000 18
//CCCC 0011 1100 3C
//EEEE 0111 1110 7E
//FFFF 1011 1111 FD 花样二
//0000 1101 1111 FB
//1111 1110 1111 F7
//2222 1111 0111 EF
//3333 1111 1011 DF
//4444 1111 1101 BF
//5555 1111 1110 7F
//6666 1111 1101 BF
//7777 1111 1011 DF
//8888 1111 0111 EF
//9999 1110 1111 F7
//AAAA 1101 1111 FB
//BBBB 1011 1111 FD
//CCCC 0111 1111 FE 花样三
//DDDD 0011 1111 FC
//EEEE 0001 1111 F8
//FFFF 0000 1111 F0
//0000 0000 0111 E0
//1111 0000 0011 C0
//2222 0000 0001 80
//3333 0000 0000 00
//4444 1000 0000 01
//5555 1100 0000 03
//6666 1110 0000 07
//7777 1111 0000 0F
//8888 1111 1000 1F
//9999 1111 1100 3F
//AAAA 1111 1110 7F
//BBBB 1111 1100 3F
//CCCC 1111 1000 1F
//DDDD 1111 0000 0F
//EEEE 1110 0000 07
//FFFF 1100 0000 03
//0000 1000 0000 01
//1111 0000 0000 00
#include
void main(void)
{//定义花样
//花样一 //花样二
const unsigned char designa[49]={0xFF,0x7E,0xBD,0xDB,0xE7,0xDB,0xBD,0x7E,0x3C,0x18,0x00,0x18,0x3C,0x7E,0xFD,0xFB,0xF7,0xEF,0xDF,
0xBF,0x7F,0xBF,0xDF,0xEF,0xF7,0xFB,0xFD,0xFE,0xFC,0xF8,0xF0,0xE0,0xC0,0x80,0x00,0x01,0x03,0x07,
0x0F,0x1F,0x3F,0x7F,0x3F,0x1F,0x0F,0x07,0x03,0x01,0x0}; //花样三
const unsigned char designb[19]={0x28,0xEB,0x32,0xA2,0xE1,0xA4,0x24,0xEA,0x20,0xE0,0x40,0x00,0x1C,0x08,0x14,0x54,0x00};
//0 1 2 3 4 5 6 7 8 9 A B C D E F
unsigned int a; //定义循环用的变量
unsigned char b; //在C51 编程中因内存有限尽可能注意变量类型的使用
//尽可能使用少字节的类型,在大型的程序中很受用
do
{
for (b=0; b {
for (a=1; a P1 = designa[b];//读已定义的花样数据并写花样数据到P1口,
P0 = designb[b];//读已定义的花样数据并写花样数据到P0口,(未启用)
//数码管与LED同步显示进行的步骤0000 1111 2222 3333 4444 5555 6666 7777
P2 = 0;
}
}while(1);
}