《单片机C语言程序设计实训100例——基于8051+Proteus仿真》第03篇源代码

综合设计中只有HEX没有C代码,希望有的发我一份,感激不尽

第1个回答  2013-07-05
//=======================
// 8个LED 闪烁
// 用来回循环亮
//-------------------------------------
#include <reg51.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
uchar i ;
//--------------------------------
void DelayMS(uint ms)
{
uchar t;
while(ms--) for (t=0;t<120;t++);
}
//----------------------------------
void main()
{
P2= 0xfe;
while (1)
{
for ( i = 0; i < 7; i++)
{P2 =_crol_(P2,1); //左移
DelayMS(200);
}
for ( i = 0; i < 7; i++)
{P2 =_cror_(P2,1); //右移
DelayMS(200);
}
}
}