源代码如下:
#include"reg52.h" typedef unsigned int u16; typedef unsigned char u8; sbit LED1=P2^0; void time_dely(u16 time)//有一定延时,大约10us { while(time--); } void main() { while(1) { LED1=0;//为0时,有电位差,会亮 time_dely(50000);//约等于500ms,0.5s LED1=1;//灯灭 time_dely(50000); } }