background image

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

——

基于 8051+Proteus 仿真

 

马灯效果 */ 

#include<reg51.h> 

#include<intrins.h> 

#define uchar unsigned char 

#define uint unsigned int 

//

 

延时

void DelayMS(uint x) 

uchar i; 

while(x--) 

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

//

 

主程序

void main() 

P0=0xfe; 

while(1) 

P0=_crol_(P0,1); //P0 

 

的值向左循环移动

DelayMS(150); 

03  8 只

 LED 

 

左右来回点亮

/*   名称:8 只

 LED 

 

左右来回点亮

说明:程序利用循环移位函数_crol_和_cror_

 

形成来回滚动的效果 */ 

#include<reg51.h> 

#include<intrins.h> 

#define uchar unsigned char 

#define uint unsigned int 

//

 

延时

                                 

陈文亚

2