void Delay(unsigned int xx) //输入 xx :ms{while(xx--){Delay1ms();}}void Delay1ms() //@11.0592MHz 1ms{unsigned char i, j;_nop_();_nop_();_nop_();i = 11;j = 190;do{while (--j);} while (--i);}
#include <reg52.h>int main(){p1 = 0xfe;while(1){p1 = _crol_(p1, 1);Delay(500);}return 0;}
void BEEP_ON() //蜂鸣器打开,持续时间:500ms ,{sbit beep = p2 ^ 3;beep = 0; //蜂鸣器打开Delay(500);//延时beep = 1;//蜂鸣器关闭}
原文:http://www.cnblogs.com/jianghanxv/p/5525409.html