仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)
代碼如下
/*
*流水燈右移*
*/
#include <reg51.h>
typedef unsigned char uint8;
typedef unsigned int uint16;
void delay(uint16 x)
{
uint16 i,j;
for(i = x; i > 0; i --)
for(j = 114; j > 0; j --);
}
void main()
{
uint8 j = 0;
while(1)
{
P0 = ~(0x80 >> j++);
delay(200);
if(j == 8)
{
j = 0;
}
}
}
Keil代碼與Proteus仿真下載:
流水燈右移.7z
(95.29 KB, 下載次數: 15)
2023-6-2 19:49 上傳
點擊文件名下載附件
|