第1篇:Arduino与ESP32开发板的安装方法
第2篇:ESP32 helloword第一个程序示范点亮板载LED
第3篇:vscode搭建esp32 arduino开发环境
第4篇:vscode+platformio搭建esp32 arduino开发环境
第5篇:doit_esp32_devkit_v1使用pmw呼吸灯实验
第6篇:ESP32连接无源喇叭播放音乐《涛声依旧》
线路连接图:
示范代码:
PlatformIO.ini
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html[env:esp32doit-devkit-v1]
platform = espressif32
board = esp32doit-devkit-v1
framework = arduino
upload_speed = 921600
upload_port = COM8
monitor_port = COM8
main.cpp
#include <Arduino.h>// put function declarations here:
int myFunction(int, int);
int input_pin = 5;
int out_pin = 16;void setup() {// put your setup code here, to run once:pinMode(input_pin,INPUT_PULLUP); //输入进行上拉,默认是高电平状态pinMode(out_pin,OUTPUT);
}void loop() {// put your main code here, to run repeatedly:if(!digitalRead(input_pin)){digitalWrite(out_pin,HIGH);tone(13,1480,1);}else{digitalWrite(out_pin,LOW);tone(13,0,1);}
}// put function definitions here:
int myFunction(int x, int y) {return x + y;
}
参考:
第7篇示范esp32连接按钮控制LED连接无源喇叭_哔哩哔哩_bilibili