标题:
51单片机流水灯从左到右 源程序+电路图
[打印本页]
作者:
Scorpionx
时间:
2019-10-12 12:33
标题:
51单片机流水灯从左到右 源程序+电路图
流水灯左右走程序.docx
(12.96 KB, 下载次数: 7)
2019-10-12 12:32 上传
点击文件名下载附件
下载积分: 黑币 -5
图加程序
SK6$MFA$[5}BP2FSO3`19~T.png
(85.19 KB, 下载次数: 45)
下载附件
2019-10-12 12:33 上传
单片机源程序如下:
#include <REG52.H>
void Delay1ms(unsigned int count)
{
unsigned int i,j;
for(i=0;i<count;i++)
for(j=0;j<120;j++);
}
main()
{
unsigned char LEDIndex = 0;
bit LEDDirection = 1;
while(1)【满足条件执行下面程序】
{
if(LEDDirection)
P1 = ~(0x01<<LEDIndex);【满足】<<表示逻辑移位
else
P1 = ~(0x80>>LEDIndex);【不满足】~表示按位取反
if(LEDIndex==7)
LEDDirection = !LEDDirection;
LEDIndex = (LEDIndex+1)%8; 【%】取余数
Delay1ms(100);
}
}
复制代码
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1