⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 light--led.c

📁 点亮LED灯
💻 C
字号:
//小灯实验一
//功能:实现第一个小灯的不停闪烁
#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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -