一、环境搭建(VScode + PlatformIO IDE)
1、官网下载VScode;

2、安装最新的插件(C/C++、PlatformIO IDE、python、Chinese);

3、在PlatformIO IDE中新建工程:Platforms------Projects------Create New Project------输入Name(ESP32demo)、Board(Espressif ESP32 Dev Module)、Framework(Arduino)------取消勾选------将新建文件夹保存到桌面或者其他路径中------确认。

创建工程:

4、硬件

二、LED闪烁
1、新建.cpp文件------编写LED闪烁代码------选择端口------编译------下载。

2、编译;下载;端口选择。

3、LED代码:
cpp
#include <Arduino.h>
#define LED 2 //板载LED在第2脚
void setup() {
// put your setup code here, to run once:
pinMode(LED, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(LED, HIGH); //高电平
delay(1000); //等待1000毫秒
digitalWrite(LED, LOW); //低电平
delay(1000); //等待1000毫秒
}
4、现象(蓝色LED)D2

三、快捷键设置
前进;后退;编译;下载。
