background image

单片机 C 语言程序设计实训 100

——

基于 8051+Proteus 仿真

单片机 语言程序设计实训 100 

——基于 8051+ Proteus 仿真

01 闪烁的

 LED 

/*   名称:闪烁的

 LED 

说明:LED 

 

按设定的时间间隔闪烁 */ 

#include<reg51.h> 

#define uchar unsigned char 

#define uint unsigned int 

sbit LED=P10; 

//

 

延时

void DelayMS(uint x) 

uchar i; 

while(x--) 

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

}

 //

 

主程序

void main() 

while(1) 

LED=~LED; 

DelayMS(150); 

02  

 

从左到右的流水灯

/*   

 

名称:从左到右的流水灯

说明:接在 P0 口的 8 个 LED

从左到右循环依次点亮,产生走

                                 

陈文亚

1