//两个led灯循环左移
#include<reg52.h>
#include<intrins.h>
unsigned char temp;
void delay(unsigned int z); // 延时子程序
void main()
{
temp=0xfa; //led 1,3
P2=temp;
while(1)
{
delay(1000);
temp = _crol_(temp,1); //循环左移1位,点亮下一个LED
P2 = temp;
}
}
void delay(unsigned int z) // 延时子程序
{
unsigned int x,y;
for(x = z; x >0; x–)
for(y = 110; y >0; y–);
}