请问以下有关单片机跑马灯的C语言程序各语句的含义(详细)
#include<reg51.h>#include<intrins.h>voidDelay10ms(unsignedintc);voidmain(void){unsign...
#include <reg51.h>
#include <intrins.h>
void Delay10ms(unsigned int c);
void main(void)
{
unsigned char LED;
LED = 0x01;
while(1)
{
P0 = LED;
Delay10ms(50);
LED = _crol_(LED,1);
}
}
void Delay10ms(unsigned int c)
{
unsigned char a, b;
for (;c>0;c--)
{
for (b=38;b>0;b--)
{
for (a=130;a>0;a--);
}
}
} 展开
#include <intrins.h>
void Delay10ms(unsigned int c);
void main(void)
{
unsigned char LED;
LED = 0x01;
while(1)
{
P0 = LED;
Delay10ms(50);
LED = _crol_(LED,1);
}
}
void Delay10ms(unsigned int c)
{
unsigned char a, b;
for (;c>0;c--)
{
for (b=38;b>0;b--)
{
for (a=130;a>0;a--);
}
}
} 展开
1个回答
展开全部
#include <reg51.h> //51头文件
#include <intrins.h> //包含移位函数_crol_
void Delay10ms(unsigned int c); //延时函数声明
void main(void)
{
unsigned char LED;
LED = 0x01; //一个unsigned char有8位,每一位代表了一个灯,初始点亮第一盏灯
while(1)
{
P0 = LED; //点亮一盏灯
Delay10ms(50); //延时500ms,让其量一会儿
LED = _crol_(LED,1); //向左移位函数,比如 0x01 --> 0x02 --> 0x04 -->0x08 ---> 0x10
}
}
void Delay10ms(unsigned int c) //延时函数
{
unsigned char a, b;
for (;c>0;c--) //三重循环延时,大约延时10ms
{
for (b=38;b>0;b--)
{
for (a=130;a>0;a--);
}
}
}
#include <intrins.h> //包含移位函数_crol_
void Delay10ms(unsigned int c); //延时函数声明
void main(void)
{
unsigned char LED;
LED = 0x01; //一个unsigned char有8位,每一位代表了一个灯,初始点亮第一盏灯
while(1)
{
P0 = LED; //点亮一盏灯
Delay10ms(50); //延时500ms,让其量一会儿
LED = _crol_(LED,1); //向左移位函数,比如 0x01 --> 0x02 --> 0x04 -->0x08 ---> 0x10
}
}
void Delay10ms(unsigned int c) //延时函数
{
unsigned char a, b;
for (;c>0;c--) //三重循环延时,大约延时10ms
{
for (b=38;b>0;b--)
{
for (a=130;a>0;a--);
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询