选用P1口作为输出口,接8只发光二极管,编程实现使8个发光二极管每隔200ms循环依次左移点亮.

(采用软件延时子程序实现延时200ms,假设低电平点亮发光二极管,初始状态为P1.0口灯亮)要使用汇编语言

#include <reg51.h>
#define LED P1 //宏定义,使用LED代替P1口(相当于LED=P1)
#define uchar unsigned char //用uchar代替unsigned char方便操作
#define uint unsigned int
/*------------------time ms延时函数-----------------*/
void delay_ms(uint time)
{
uchar tres;
for(;time>0;time--)
{
tres=;
while(tres--);

}
void in()
{
uchar t;
LED=0X01;//P1=B
while(1)//ˀѭ»·,²»ͣµĵぁº͏¨ðLED
{
for(t=0;t
温馨提示:答案为网友推荐,仅供参考