1、1.第一个发光管以间隔200ms闪烁。2.8个发光管由上至下间隔1s流动,其中每个管亮500ms,灭500ms。3.8个发光管来回流动,第个管亮100ms。4.用8个发光管演示出8位二进制数累加过程。5.8个发光管间隔200ms由上至下,再由下至上,再重复一次,然后全部熄灭再以300ms间隔全部闪烁5次。重复此过程。6.间隔300ms第一次一个管亮流动一次,第二次两个管亮流动,依次到8个管亮,然后重复整个过程。7.间隔300ms先奇数亮再偶数亮,循环三次;一个灯上下循环三次;两个分别从两边往中间流动三次;再从中间往两边流动三次;8个全部闪烁3次;关闭发光管,程序停止。1#include #de
2、fine uint unsigned int sbit led1=P10; void delay(); void main() while(1) led1=0; delay(); led1=1;delay(); void delay() uint x,y;for(x=200;x0;x-)for(y=100;y0;y-);2#include#include#define uint unsigned int#define uchar unsigned charsbit p1=P10;uchar a;void delay();void main() a=0xfe; P1=a; while(1) a=
3、_crol_(a,1); delay(); P1=a; delay(); void delay() uint b; for(b=55000;b0;b-);3#include #include #define uint unsigned int #define uchar unsigned char void delay() uint x,y;for(x=100;x0;x-)for(y=110;y0;y-);void main() uchar a,i;while(1) a=0xfe; for(i=0;i8;i+) P1=a; delay(100); a=_crol_(a,1); a=0x7f;f
4、or(i=0;i8;i+) P1=a; delay(100); a=_cror_(a,1);4#include #include #define uint unsigned int #define uchar unsigned char void delay(uint a) uint x,y;for(x=a;x0;x-)for(y=110;y0;y-);void main() uchar b;while(1) b+;P1=b;delay(200);5#include #include #define uint unsigned int #define uchar unsigned char v
5、oid main() uchar a,i,j;while(1) for(j=0;j2;j+)a=0xfe; for(i=0;i8;i+) P1=a; delay(200); a=_crol_(a,1); a=0x7f;for(i=0;i8;i+) P1=a; delay(200); a=_cror_(a,1); P1=0xff;for(j=0;j0;x-)for(y=110;y0;y-);6#include #include #define uint unsigned int #define uchar unsigned char void delay() uint x,y;for(x=300
6、;x0;x-)for(y=110;y0;y-);void main() uchar a,i,j;while(1) a=0xfe; for(j=0;j8;j+)for(i=0;i8-j;i+) P1=a; delay(200); a=_crol_(a,1); a=_crol_(a,j); P1=0xff; a=a1;7 #include #include #define uint unsigned int #define uchar unsigned char void delay(uint z) uint x,y;for(x=z;x0;x-)for(y=110;y0;y-);void main
7、() uchar a,i,j;for(j=0;j3;j+) P1=0x55; delay(300); P1=0xaa;delay(300); for(j=0;j3;j+) a=0xfe;for(i=0;i8;i+)P1=a; delay(300); a=_crol_(a,1);P1=0xff;for(j=0;j3;j+) P1=0x7e; delay(300); P1=0xbd;delay(300); P1=0xdb; delay(300); P1=0xe7;delay(300); P1=0xff;for(j=0;j3;j+) P1=0xe7; delay(300); P1=0xdb;delay(300); P1=0xbd; delay(300);P1=0x7e;delay(300); P1=0xff;for(j=0;j6;j+) P1=P1; delay(300); P1=0xff;while(1);