#include\
sbit L0= P0^5; sbit L1= P0^6; sbit L2= P0^7; sbit L3= P2^7; sbit L4= P2^6; sbit L5= P2^5; sbit L6= P2^4; sbit L7= P2^3; sbit L8= P2^2; sbit L9= P2^1; sbit L10=P2^0; sbit L11=P1^0; sbit L12=P1^1; sbit L13=P1^2; sbit L14=P1^3; sbit L15=P0^0; sbit L16=P0^1; sbit L17=P0^2; sbit L18=P0^3; sbit L19=P0^4; int a,b,time;
void main() { void shun(); void ni(); void shangxia(); void xiashang(); void zhongjian(); void delay500ms(void); while(1) { shun();
/*灯全亮10s*/
for(time=0;time<20;time++) { delay500ms(); }
P0=0xff;P1=0xff;P2=0xff;//将灯全部熄灭 ni();
/*灯全亮10s*/
for(time=0;time<20;time++) { delay500ms(); }
P0=0xff;P1=0xff;P2=0xff;//将灯全部熄灭 shangxia();
/*灯全亮10s*/
for(time=0;time<20;time++) {
}
delay500ms(); }
P0=0xff;P1=0xff;P2=0xff;//将灯全部熄灭 xiashang();
/*灯全亮10s*/
for(time=0;time<20;time++) { delay500ms(); }
P0=0xff;P1=0xff;P2=0xff;//将灯全部熄灭 zhongjian();
/*灯全部点亮50s*/ for(time=0;time<100;time++) { delay500ms(); } /*灯闪烁10s*/ for(time=0;time<10;time++) { P0=0x00;P1=0x00;P2=0x00; delay500ms(); P0=0xff;P1=0xff;P2=0xff; delay500ms(); } }
void delay500ms(void) //误差 0us {
unsigned char x,y,z; for(z=205;z>0;z--)
for(y=116;y>0;y--) for(x=9;x>0;x--); }
/*顺时针转*/ void shun() { for(a=0;a<2;a++) { L0=0; delay500ms();
L0=1;L1=0; delay500ms(); L1=1;L2=0; delay500ms(); L2=1;L3=0; delay500ms(); L3=1;L4=0; delay500ms(); L4=1;L5=0; delay500ms(); L5=1;L6=0; delay500ms(); L6=1;L7=0; delay500ms(); L7=1;L8=0; delay500ms(); L8=1;L9=0; delay500ms(); L9=1;L10=0; delay500ms(); L10=1;L11=0; delay500ms(); L11=1;L12=0; delay500ms(); L12=1;L13=0; delay500ms(); L13=1;L14=0; delay500ms(); L14=1;L15=0; delay500ms(); L15=1;L16=0; delay500ms(); L16=1;L17=0; delay500ms(); L17=1;L18=0; delay500ms(); L18=1;L19=0; delay500ms(); L19=1; }
L0=0;delay500ms(); L1=0;delay500ms(); L2=0;delay500ms(); L3=0;delay500ms();
L4=0;delay500ms(); L5=0;delay500ms(); L6=0;delay500ms(); L7=0;delay500ms(); L8=0;delay500ms(); L9=0;delay500ms(); L10=0;delay500ms(); L11=0;delay500ms(); L12=0;delay500ms(); L13=0;delay500ms(); L14=0;delay500ms(); L15=0;delay500ms(); L16=0;delay500ms(); L17=0;delay500ms(); L18=0;delay500ms(); L19=0; }
/*逆时针转*/ void ni() { for(a=0;a<2;a++) { L0=0; delay500ms(); L0=1;L19=0; delay500ms(); L19=1;L18=0; delay500ms(); L18=1;L17=0; delay500ms(); L17=1;L16=0; delay500ms(); L16=1;L15=0; delay500ms(); L15=1;L14=0; delay500ms(); L14=1;L13=0; delay500ms(); L13=1;L12=0; delay500ms(); L12=1;L11=0; delay500ms(); L11=1;L10=0;
delay500ms(); L10=1;L9=0; delay500ms(); L9=1;L8=0; delay500ms(); L8=1;L7=0; delay500ms(); L7=1;L6=0; delay500ms(); L6=1;L5=0; delay500ms(); L5=1;L4=0; delay500ms(); L4=1;L3=0; delay500ms(); L3=1;L2=0; delay500ms(); L2=1;L1=0; delay500ms(); L1=1; } L0=0;delay500ms(); L19=0;delay500ms(); L18=0;delay500ms(); L17=0;delay500ms(); L16=0;delay500ms(); L15=0;delay500ms(); L14=0;delay500ms(); L13=0;delay500ms(); L12=0;delay500ms(); L11=0;delay500ms(); L10=0;delay500ms(); L9=0;delay500ms(); L8=0;delay500ms(); L7=0;delay500ms(); L6=0;delay500ms(); L5=0;delay500ms(); L4=0;delay500ms(); L3=0;delay500ms(); L2=0;delay500ms(); L1=0; }
/*自上而下点亮*/
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库五种特效心形流水灯在线全文阅读。
相关推荐: