1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > 单片机流水灯全亮c语言程序 终极流水灯单片机C语言程序.doc

单片机流水灯全亮c语言程序 终极流水灯单片机C语言程序.doc

时间:2023-06-15 14:12:43

相关推荐

单片机流水灯全亮c语言程序 终极流水灯单片机C语言程序.doc

终极流水灯单片机C语言程序

#include

#include

#define uint unsigned int

sbit beep=P2^3;

void ji_ou();

void sx();

void shanshuo();

void two_out_in_out();

void four_out_in_out();

void delay(uint z)

{

uint x,y;

for(x=z;x>0;x--)

for(y=110;y>0;y--);

}

void main()

{

ji_ou();

sx();

two_out_in_out();

four_out_in_out();

shanshuo();

P1=0xff;

while(1);

}

void ji_ou()

{

uint t;

for(t=0;t<3;t++)

{

P1=0xaa;

delay(300);

P1=0x55;

delay(300);

}

}

void sx()

{

uint a,i,j;

for(j=0;j<3;j++)

{

a=0xfe;

for(i=0;i<8;i++)

{

P1=a;

//delay(200);

beep=0;

delay(50);

beep=1;

delay(50);

a=_crol_(a,1);

}

a=0x7f;

for(i=0;i<8;i++)

{

P1=a;

//delay(200);

beep=0;

delay(50);

beep=1;

delay(50);

a=_cror_(a,1);

}

}

}

void two_out_in_out()

{

uint i,j;

P1=0xff;

for(i=0;i<3;i++)

{

P1=0x7e;

delay(300);

P1=0xbd;

delay(300);

P1=0xdb;

delay(300);

P1=0xe7;

delay(300);

}

P1=0xff;

for(j=0;j<3;j++)

{

P1=0xe7;

delay(300);

P1=0xdb;

delay(300);

P1=0xbd;

delay(300);

P1=0x7e;

delay(300);

}

}

void four_out_in_out()

{

uint k;

P1=0xff;

for(k=0;k<3;k++)

{

P1=0x3c;

delay(300);

P1=0xc3;

delay(300);

}

P1=0xff;

for(k=0;k<3;k++)

{

P1=0xc3;

delay(300);

P1=0x3c;

delay(300);

}

}

void shanshuo()

{

uint k;

P1=0xff;

for(k=0;k<6;k++)

{

P1=~P1;

delay(300);

beep=0;

delay(50);

beep=1;

delay(50);

}

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。