📄 l1-1.c
字号:
/**************************** ***********************************
程序名称:MyProject.c
功能描述:依次点亮接在P1口上的LED,并无限循环
作者名称:张三
创建时间:2008-3-28
****************************************************************/
#include <reg51.h>
void main( void )
{
data unsigned char LedBuff; //定义无符号字符型变量LedBuff并存放在片内RAM中
for( ; ; ){
LedBuff=0x01 ; P1=LedBuff ; // 点亮接在P1.0上的LED
Delay( 1000 ) ; // 调用延时函数
LedBuff=0x02 ; P1=LedBuff ;
Delay( 1000 ) ;
LedBuff=0x04 ; P1=LedBuff ;
Delay( 1000 ) ;
LedBuff=0x08 ; P1=LedBuff ;
Delay( 1000 ) ;
LedBuff=0x10 ; P1=LedBuff ;
Delay( 1000 ) ;
LedBuff=0x20 ; P1=LedBuff ;
Delay( 1000 ) ;
LedBuff=0x40 ; P1=LedBuff ;
Delay( 1000 ) ;
LedBuff=0x80 ; P1=LedBuff ;
Delay( 1000 ) ;
}
}
/**************************************************************
函数名称:Delay( unsigned int x)
功能描述:若晶振频率为12MHz,延时x
作者名称:张三
创建时间:2008-3-28
***************************************************************/
void Delay( unsigned int x)
{
if( x==0 ) return;
while( x!=0 ) x--;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -