#include <REG52.H> #include<INTRINS.H>
代码如下:好好研究,很有用的。可以改成按键控制多种花样流水灯,原理是一样的
void main(void) {
unsigned char ucTimes;
#defineDELAY_TIME 200
while(1)
{
for(ucTimes=0;ucTimes<7;ucTimes++){
LED_PORT1=table1[ucTimes];
time(DELAY_TIME);
}
}}
/********延时**********/
void delay_5us(void)
{_nop_();
_nop_();}
void delay_50us(void)
{unsigned char i;
for(i=0;i<4;i++)
{delay_5us();
}
}
void delay_100us(void)
{delay_50us();
delay_50us();}
void time(unsigned int ucMs)
{unsigned char j;
while(ucMs>0)
{for(j=0;j<15;j++)
delay_100us();
ucMs--;
}
}