/**************************************************************************************
* LED闪烁实验 *
实现现象:下载程序后D1指示灯闪烁
注意事项:无
***************************************************************************************/
#include "reg52.h" //此文件中定义了单片机的一些特殊功能寄存器
typedef unsigned int u16; //对数据类型进行声明定义
typedef unsigned char u8;
sbit led=P2^0; //将单片机的P2.0端口定义为led
/*******************************************************************************
* 函 数 名 : delay
* 函数功能 : 延时函数,i=1时,大约延时10us
*******************************************************************************/
void delay(u16 i)
{
while(i--);
}
/*******************************************************************************
* 函 数 名 : main
* 函数功能 : 主函数
* 输 入 : 无
* 输 出 : 无
*******************************************************************************/
void main()
{
while(1)
{
led=0;
delay(50000); //大约延时450ms
led=1;
delay(50000); //大约延时450ms
}
}
相关文章









