light--led.c

来自「点亮LED灯」· C语言 代码 · 共 32 行

C
32
字号
//小灯实验一
//功能:实现第一个小灯的不停闪烁
#include <reg52.h>
//*define all the lights bit*
sbit light0 = P1^0;
sbit light1 = P1^1;
sbit light2 = P1^2;
sbit light3 = P1^3;
sbit light4 = P1^4;
sbit light5 = P1^5;
sbit light6 = P1^6;
sbit light7 = P1^7;


void Delay() //the function of delay 
{
  unsigned int i;
  for (i=0; i<20000; i++) ;
}

void main() // the main function(must define)
{
  while (1) // when the parameter is "1" ,the body will always loop
{
  	light0=0;  //ignite the light0
	Delay();   //delay for a little while
    light0=1;  //dark the light0
	Delay();
  }  
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?