*/
#include #define uint unsigned int #define uchar unsigned char uchar code table[]={0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00}; // 逐个点亮0~7 uchar code table1[]={0x7f,0x3f,0x1f,0x0f,0x07,0x03,0x01,0x00}; // 逐个点亮7~0 uchar code table2[]={0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f,0xff}; // 逐个灭0~7 uchar code table3[]={0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff}; // 逐个灭7~0 /***********************************************************/ void delay(uint t); //延时 void zg(uint t,uchar a);//两边逐个亮 void qs(uint t,uchar a);//全部闪烁 void zgxh(uint t,uchar a); // 逆时针逐个点亮 //void zgxh1(uint t,uchar a); // 顺时针逐个点亮 void djs(uint t,uchar a); //对角闪 void lbzgm(uint t,uchar a);//两边逐个灭 //void sszgm(uint t,uchar a); // 顺时针逐个灭 void nszgm(uint t,uchar a); // 逆时针逐个灭 void sztl(uint t,uchar a);//顺时逐个同步亮 void nztl(uint t,uchar a);//逆时逐个同步亮 void sztm(uint t,uchar a);//顺时逐个同步灭 void nztm(uint t,uchar a);//逆时逐个同步灭 void hwzjl(uint t,uchar a); //横往中间亮 void hwzjm(uint t,uchar a); //横往中间灭 //void swzjl(uint t,uchar a); //竖往中间亮 //void swzjm(uint t,uchar a); //竖往中间灭 void nzdl(uint t,uchar a); //逆时逐段亮 void nzdgl(uint t,uchar a); //逆时逐段一个点亮 void jgs(uint t,uchar a); //间隔闪 /**********************************************************/ void zg(uint t,uchar a)//两边逐个亮 { uchar i,j; for(j=0;jvoid qs(uint t,uchar a) //全部闪烁 { uchar j; for(j=0;jP0=P1=P2=P3=0xff; delay(t); P0=P1=P2=P3=0x00; delay(t); } } void zgxh(uint t,uchar a) // 逆时针逐个点亮 { uchar i,j; for (j=0;j} void nszgm(uint t,uchar a) // 逆时针逐个灭 { uchar i,j; for(j=0;jvoid zgxh1(uint t,uchar a) // 顺时针逐个点亮 { uchar i,j; for (j=0;j{ P2=table1[i]; delay(t); } for(i=0;i<8;i++) { P3=table1[i]; delay(t); } for(i=0;i<8;i++) { P1=table1[i]; delay(t); } for(i=0;i<8;i++) { P0=table[i]; delay(t); } } } */ /* void sszgm(uint t,uchar a) // 顺时针逐个灭 { uchar i,j; for(j=0;jfor (i=0;i<8;i++) { P1=table3[i];delay(t); } for (i=0;i<8;i++) { P0=table2[i];delay(t); } } } */ void djs(uint t,uchar a) //对角闪 { uchar j; for(j=0;jvoid lbzgm(uint t,uchar a)//两边逐个灭 { uchar i,j; for (j=0;jP0=P2=0x00; P3=0x01;delay(t); for(i=7;i>1;i--) { P1=table[i-1];P3=table1[i-2]; delay(t); } P1=0xfe;P3=0xff;delay(t); P1=0xff;P2=0x01;delay(t); for(i=7;i>1;i--) { P0=table1[i-1]; P2=table1[i-2]; delay(t); } P0=0x7f;P2=0xff;delay(t); P0=0xff;delay(t); } } void sztl(uint t,uchar a)//顺时逐个同步亮 { uchar i,j; for(j=0;jvoid nztl(uint t,uchar a)//逆时逐个同步亮 { uchar i,j; for(j=0;jvoid sztm(uint t,uchar a)//顺时逐个同步灭 { uchar i,j; for(j=0;jvoid nztm(uint t,uchar a)//逆时逐个同步灭 { uchar i,j; for(j=0;j{ P0=table3[i]; P1=P2=P3=table2[i]; delay(t); } } } void hwzjl(uint t,uchar a) //横往中间亮 { uchar i,j; for (j=0;jvoid hwzjm(uint t,uchar a) //横往中间灭 { uchar i,j; for (j=0;jvoid swzjl(uint t,uchar a) //竖往中间亮 { uchar i,j; for (j=0;jvoid swzjm(uint t,uchar a) //竖往中间灭 { uchar i,j; for (j=0;jvoid nzdl(uint t,uchar a) //逆时逐段亮 { uchar i,j; for (j=0;jdelay(t); } P0=0xff; for(i=0;i<8;i++) { P1=table[i]; delay(t); } P1=0xff; for(i=0;i<8;i++) { P3=table[i]; delay(t); } P3=0xff; for(i=0;i<8;i++) { P2=table[i]; delay(t); } P2=0xff; } } void nzdgl(uint t,uchar a) //逆时逐段一个点亮 { uchar i,j,k,l; for (j=0;jl=_crol_(l,1); P1=P2=P3=l; delay(t); } } }