流水灯先依次点亮然后同时闪,同时灭的c语言程序

流水灯先依次点亮然后同时闪,同时灭的c语言程序,第1张

#include <reg51.h>

#define uint unsigned int

#define uchar unsigned char

uint num

void delay(uint x)

{

uint i,j

for(i=0i<xi++)

for(j=0j<120j++)

}

void main()

{

uchar temp

while(1)

{

temp=0xfe

for(num=0num<7num++)

{

P1=temp

temp=temp<<1

delay(500) //0.5s

}

for(num=0num<8num++)

{

P1=temp

temp=temp>>1|0x80

delay(500)

}

P1=0xff

delay(500)

for(num=0num<4num++)

{

P1=0X00

delay(500)

P1=0xff

delay(500)

}

}

}

#include<reg51.h>

void delay(int a)

{

while(a--)

}

main()

{

unsigned char i

while(1)

{

P0=0xff

for(i=0i<8i++){P0=P0<<亏芦1delay(30000)}

P0=0x00

for(i=0i<销伏带8i++){P0=(P0>>厅橡1)|0x80delay(30000)}

}

}


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/12550445.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-26
下一篇 2023-05-26

发表评论

登录后才能评论

评论列表(0条)

保存