#include <reg51.h> /
#include <intrins.h>
void delayms(unsigned char ms)
// 延时子程序
{
unsigned char i;
while(ms--)
{
for(i = 0; i < 120; i++);
}
}
main()
{
unsigned char LED;
LED = 0xfe; //0xfe = 1111 1110
while(1)
{
P2 = LED;
delayms(250);
LED = LED << 1; //循环右移1位,点亮下一个LED "<<"为左移位
if(P2 == 0x00 ) {LED = 0xfe; } // 0xfe = 1111 1110
}
}
我不太明白的是这段延时程序是怎么样的逻辑,初学51机
void delayms(unsigned char ms)
// 延时子程序
{
unsigned char i;
while(ms--)
{
for(i = 0; i < 120; i++);
}
}
然后后面又出现delayms(250); 这个句子,这个句子中间的250表示什么意思???
难道没有直接靠晶振延时的方法吗?
追答我是学通用程序的,对单片机研究不深,抱歉