写在前面
学习开发板,点亮第一个LED,是一个具有里程碑意义的重大事件。
相当于学习一门编程语言,成功配置好编译环境,并正确输出了一句"hello world"。
硬件电路

示例代码
#include "reg52.h"
sbit LED1=P2^0; //将 P2.0 管脚定义为 LED1
sbit LED2=P2^1;
sbit LED3=P2^2;
sbit LED4=P2^3;
sbit LED5=P2^4;
sbit LED6=P2^5;
sbit LED7=P2^6;
sbit LED8=P2^7;
void main()
{
LED1=0; //LED1 端口设置为低电平
LED2=0;
LED3=0;
LED4=0;
LED5=0;
LED6=0;
LED7=0;
LED8=0;
while(1)
{
}
}
实验结果
开发板上的8个LED灯全部点亮!
完结,撒花~~~