1、电路原理图:原件清单:1、51单片机 x1、40Pin 座 x12、LED x32(建议用 5mm 七彩的)3、电阻470 x334、晶振12MHz x15、10uf 电解电容 x1、谐振瓷片电容30pf x26其他的可以看自己的爱好去加7、其实也可以不用那么多的电阻,用几个排阻就OK了。效果展示:作品程序:#include #define uchar unsigned charuchar flag=200;/uchar code Tab1=0xFE,0xFD,0xFB,0xF7,0xEF,0xDF,0xBF,0x7F,0xFF;/暗中左移 向下uchar code Tab2=0x7F,0xB
2、F,0xDF,0xEF,0xF7,0xFB,0xFD,0xFE,0xFF;/暗中右移 向上uchar code Tab3=0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0x00;/亮中左移 向下uchar code Tab4=0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01,0x00;/亮中右移 向上uchar code Tab11=0xFE,0xFC,0xF8,0xF0,0xE0,0xC0,0x80,0x00,0xff;/暗中左移 向下uchar code Tab22=0x7F,0x3F,0x1F,0x0F,0x07,0x03,
3、0x01,0x00,0xff;/uchar code Tab33=0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xFF;uchar code Tab44=0x01,0x03,0x07,0x0F,0x1F,0x3F,0x7F,0xFF;uchar code Tab55=0x08,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff,0xff;uchar code Tab5=0x00,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xff;uchar code Tab6=0x00,0x01,0x03,0x07,0x0F,0x1F,0
4、x3F,0x7F,0xff;uchar code Tab7=0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe;uchar code Tab8=0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f;/void shansuo();void xl();/void delay(void) unsigned char m,n;for(m=0;m0;flag=flag-50)P0=0xff;P1=0xff;P2=0xff;P3=0xff;for(i=0;i0;flag=flag-10)for(i=0;i8;i+) P2=0xff;P3=0xff;P
5、1=Tab1i;P0=Tab1i;delay(); for(i=0;i9;i+) P1=0xff;P0=0xff;P2=Tab1i;P3=Tab1i;delay();flag=10;for(i1=0;i130;i1+)for(i=0;i8;i+) P2=0xff;P3=0xff;P1=Tab1i;P0=Tab1i;delay(); for(i=0;i9;i+) P1=0xff;P0=0xff;P2=Tab1i;P3=Tab1i;delay();flag=200;/void js(void)/结束uchar i;hy2_3();for(i=0;i3;i+) P0=0xff;P2=0xff;del
6、ay();delay();P0=0x00;P2=0x00;delay();delay();/for(i=0;i3;i+) P1=0xff;P3=0xff;delay();delay();P1=0x00;P3=0x00;delay();delay();/for(i=0;i3;i+) P1=0x00;P3=0x00;P0=0x00;P2=0x00;delay();delay();P1=0xff;P3=0xff;P0=0xff;P2=0xff;delay();delay();/void main(void)while (1)azzy_1();/hy2(); /暗中逆时针转 360(一个一个点亮)hy
7、3(); /点亮中逆时针转 360(一个一个灭)hy2_1();/暗中逆时针转 90 度。 (一个一个点亮)hy2_2();/暗中逆时针转 180 度。 (一个一个点亮)hy2_3();/暗中向下 180。 (一个一个点亮)hy3();hy2_4();/hy1(); /暗中状态逆时针旋转 90 度(一个一个亮)jc();/交叉四叶草hy1();hy4(); /点亮状态顺时针旋转 90 度(一个一个灭?jc();hy4();/hy5();/先向下伸展,然后向上伸展逐渐点亮jr();/azzy();/暗中向下边伸展azyy();/暗中向上伸展/xl(); /相邻变换(星星眨眼)shansuo();/全部灯闪烁( 一亮一灭)/led_flow1();/亮中向下lzyy(); /亮中向上led_flow1();/亮中向下azyy(); /暗中向上shansuo();/sxb();/上下半azzy();/暗中向下lzyy();/亮中向上azzy();/暗中向下lzyy();/亮中向上/shansuo();/闪烁azyy();/暗中向上lzyy();/亮中向上azyy();/暗中向上lzyy();/亮中向上shansuo();js();/结束