硬件图如下图:
元件清单如下图(有些多余了):
程序如下(C语言):
#include unsigned char led1[]={0XEF,0XEF,0X83,0XAB,0XAB,0X83,0XEF,0XEF}; //中 unsigned char led2[]={0x01,0X7D,0X45,0X45,0X65,0X45,0X7D,0X01}; //国 unsigned char led3[]={0xF7,0XD7,0X80,0X77,0XC1,0XF7,0XF7,0X00}; //生 unsigned char led4[]={0x83,0XBB,0XBB,0X83,0XBB,0XBB,0X83,0XFF}; //日 unsigned char led5[]={0xDB,0XDB,0X91,0X49,0XD0,0XD5,0XCE,0XFF}; //快 unsigned char led6[]={0xEF,0XD7,0XB7,0X81,0XF7,0XD5,0XA6,0XF7}; //乐 unsigned char led7[]={0xC1,0XDF,0XDF,0XC1,0XFD,0XFD,0XFD,0XC1}; //5 unsigned char led8[]={0x81,0XFD,0XFD,0X81,0XBF,0XBF,0XBF,0X81}; //2 unsigned char led9[]={0xC3,0XBD,0XBD,0XBD,0XBD,0XBD,0XBD,0XC3};//0 unsigned char led10[]={0xFF,0X99,0X00,0X00,0X00,0X81,0XC3,0XE7};//爱心图形 void delay(unsigned int k); void main() { unsigned char t,i,w; while(1) { P2=0XFF; P3=0XFF; for(t=0;t<100;t++) { w=0x01; for(i=0;i<8;i++) { P1=w; P0=led1[i]; delay(1); w<<=1; } } for(t=0;t<100;t++) { w=0x01; for(i=0;i<8;i++) { P1=w; P0=led2[i]; delay(1); w<<=1; } } for(t=0;t<100;t++) { w=0x01; for(i=0;i<8;i++) { P1=w; P0=led3[i]; delay(1); w<<=1; } } for(t=0;t<100;t++) { w=0x01; for(i=0;i<8;i++) { P1=w; P0=led4[i]; delay(1); w<<=1; } } for(t=0;t<100;t++) { w=0x01; for(i=0;i<8;i++) { P1=w; P0=led5[i]; delay(1); w<<=1; } } for(t=0;t<100;t++) { w=0x01; for(i=0;i<8;i++) { P1=w; P0=led6[i]; delay(1); w<<=1; } } for(t=0;t<100;t++) { w=0x01; for(i=0;i<8;i++) { P1=w; P0=led7[i]; delay(1); w<<=1; } } for(t=0;t<100;t++) { w=0x01; for(i=0;i<8;i++) { P1=w; P0=led8[i]; delay(1); w<<=1; } } for(t=0;t<100;t++) { w=0x01; for(i=0;i<8;i++) { P1=w; P0=led9[i]; delay(1); w<<=1; } } for(t=0;t<100;t++) { w=0x01; for(i=0;i<8;i++) { P1=w; P0=led10[i]; delay(1); w<<=1; } } } } void delay(unsigned int k) { unsigned char i,j; for(i=0;i<100;i++) for(j=0;j
相关文章