丿新雨丶 丿新雨丶
关注数: 123 粉丝数: 234 发帖数: 13,940 关注贴吧数: 122
【丿新雨丶】响应小九的号召 为了贴吧 这是我义不容辞责任与义务 #include<reg52.h> #include <intrins.h> #define uint unsigned int #define uchar unsigned char //延时 void delay(uint k) { uint i,j; for(i=k;i--;i>0) for(j=100;j--;j>0); } void main() { uchar temp0,temp1; uchar yi; uchar yi0,yi1; uint i,j,k,a,b; j=k=a=b=3; P0=P1=P2=P3=0x00; delay(700); P0=P1=P2=P3=0xff; for(i=2;i--;i>0) { P1=P0=0x00; delay(500); P1=P0=0xff; P3=P2=0x00; delay(500); P3=P2=0xff; } for(i=2;i--;i>0) { P0=P1=P2=P3=0x00; delay(100); P0=P1=P2=P3=0xff; delay(100); } for(i=3;i--;i>0) { //全部亮 //每个io口独自亮 //全部亮,闪三次 //P1、P2亮,P3、P0暗 } delay(500); P1=0xff,P2=0xff,P3=0x00,P0=0x00; delay(500); //四个点的流水 while(j>0) { temp0=0xfe,temp1=0x7f; P1=P3=temp0,P2=P0=temp1; delay(100); for(i=7;i--;i>0) { temp0=_crol_(temp0,1),temp1=_cror_(temp1,1); P1=P3=temp0,P2=P0=temp1; delay(100); } j--; } //全部亮,闪三次 for(i=3;i--;i>0) { P0=P1=P2=P3=0x00; delay(300); P0=P1=P2=P3=0xff; delay(300); } //四个IO口同样跟踪流水 while(k>0) { temp0=0xfe,temp1=0x7f; P1=P3=temp0,P2=P0=temp1; delay(60); for(i=7;i--;i>0) { temp0=temp0<<1,temp1=temp1>>1; P1=P3=temp0,P2=P0=temp1; delay(60); } k--; } while(k<3) { temp0=0x7f,temp1=0xfe; P1=P3=temp0,P2=P0=temp1; delay(60); for(i=7;i--;i>0) { temp0=temp0>>1,temp1=temp1<<1; P1=P3=temp0,P2=P0=temp1; delay(60); } k++; } P3=P2=0xff; //两边单个从上向下流水 yi=0xfe; P1=P0=yi; delay(50); for(i=7;i--;i>0) { yi=_crol_(yi,1); P1=P0=yi; delay(50); } P1=P0=0xff; yi=0xfe; P3=P2=yi; delay(50); for(i=7;i--;i>0) { yi=_crol_(yi,1); P3=P2=yi; delay(50); } P3=P2=0Xff; //两边单个返回流水 for(i=7;i--;i>0) { yi=_cror_(yi,1); P3=P2=yi; delay(50); } P3=P2=0xff; { yi=_cror_(yi,1); P0=P1=yi; delay(50); } //全部亮,闪三次 P0=P1=P3=P2=0xff; for(i=3;i--;i>0) { P0=P1=P2=P3=0x00; delay(100); P0=P1=P2=P3=0xff; delay(100); } yi0=0xfe,yi1=0x7f; P3=P2=yi1,P1=P0=yi0; delay(100); for(i=7;i--;i>0) { yi0=yi0<<1, yi1=yi1>>1; P1=P0=yi0,P3=P2=yi1; delay(100); } P1=P2=P3=P0=0xff; delay(200); yi0=0x7f,yi1=0xfe; P1=P0=yi0,P3=P2=yi1; for(i=7;i--;i>0) { yi0=yi0>>1,yi1=yi1<<1; P1=P0=yi0,P3=P2=yi1; delay(100); } P1=P2=P3=P0=0xff; for(i=8;i--;i>0) { P1=P1<<1; delay(50); } for(i=8;i--;i>0) //流水灯 //大循环跟踪流水 { P3=P3<<1; delay(50); } for(i=8;i--;i>0) { P2=P2>>1; delay(50); } for(i=8;i--;i>0) { P0=P0>>1; delay(50); } P1=P2=P3=P0=0xff; for(i=8;i--;i>0) { P0=P0<<1; delay(50); } for(i=8;i--;i>0) { P2=P2<<1; delay(50); } for(i=8;i--;i>0) { P3=P3>>1; delay(50); } for(i=8;i--;i>0) { P1=P1>>1; delay(50); } P0=P1=P3=P2=0xff; for(i=4;i--;i>0) { //逆向大循环跟踪流水//全部亮,闪三次 P0=P1=P2=P3=0x00; delay(100); P0=P1=P2=P3=0xff; delay(100); } temp0=0x01,temp1=0x00; P1=P0=temp0,P3=P2=temp1; delay(100); for(i=7;i--;i>0) { temp0=_crol_(temp0,1); P1=P0=temp0; delay(100); } P1=P0=0x00; temp1=0x01; P3=P2=temp1; delay(100); for(i=7;i--;i>0) { temp1=_crol_(temp1,1); P3=P2=temp1; delay(100); } temp0=0x00,temp1=0x80; P1=P0=temp0,P3=P2=temp1; delay(100); for(i=7;i--;i>0) { temp1=_cror_(temp1,1); P3=P2=temp1; delay(100); } P3=P2=0x00; temp0=0x80; P1=P0=temp0; delay(100); for(i=7;i--;i>0) { temp0=_cror_(temp0,1); P1=P0=temp0; //全部亮,只有一个暗的在流水 //全部亮,逆向一个暗在流水 delay(100); } //花样 temp0=0xaa,temp1=0x55; P1=P3=temp0,P2=P0=temp1; delay(500); for(;a--;a>0) { for(i=7;i--;i>0) { temp0=_crol_(temp0,1),temp1=_cror_(temp1,1); P1=P3=temp0,P2=P0=temp1; delay(500); } } for(;b--;b>0) { temp0=0xee,temp1=0x77; P1=P3=temp0,P2=P0=temp1; delay(300); for(i=7;i--;i>0) { temp0=_crol_(temp0,1),temp1=_cror_(temp1,1); P1=P3=temp0,P2=P0=temp1; delay(300); } } //环形逐个亮 P1=P2=P3=P0=0xff; for(i=8;i--;i>0) { P0=P0<<1; delay(50); } for(i=8;i--;i>0) { P2=P2<<1; delay(50); } for(i=8;i--;i>0) { P3=P3>>1; delay(50); } for(i=8;i--;i>0) { P1=P1>>1; delay(50); } //逐个熄灭 for(i=7;i--;i>0) { P0=~P0<<1; P0=~P0; delay(50); } P0=0xff; for(i=7;i--;i>0) { P2=~P2<<1; P2=~P2; delay(50); } P2=0xff; for(i=7;i--;i>0) { P3=~P3>>1; P3=~P3; delay(50); } P3=0xff; for(i=7;i--;i>0) { P1=~P1>>1; P1=~P1; delay(50); } P1=0xff; }
首页 1 2 3 4 5 6 下一页