热门

最新

红包

立Flag

投票

同城

我的

发布
m0_58348724
花之物
5 年前
truem0_58348724

使八个LED灯以一定的时间间隔依次亮灭
流水灯代码:
include<reg.52>
typedef unsigned int u16;
typedef unsigned char u8;
# define LED_PORT P2
void delay_10us (u16 ten_us)
{
while (tens_us--);
}
void main()
{
u8 i=0;
LED_PORT =~0X01;
delay_10us(50000);
whlie(1)
{
for(i=0;i<8;i++)
{
LED_PORT=~(0x01<<i);
delay_10us(5000);
}
}
}
1111 1110
1111 1101
1111 1011
1111 0111
1110 1111
1101 1111
1011 1111
0111 1111
调用延时函数和使用for语句循环,以及移位和取反,使LED灯以一定的时间间隔亮灭。

CSDN App 扫码分享
分享
评论
点赞
打赏
  • 复制链接
  • 举报
下一条:
生命的意义存在于你每天为之努力,你对哪个东西有用,哪个东西对你同样有用,这种意义就存在了
立即登录