如何修复 ESP32 PlatformIO error: 'LED_BUILTIN' was not declared in this scope
问题:
尝试使用 PlatformIO 编译 ESP32 固件时,你看到此错误消息:
led_builtin_error.txt
src/main.cpp: In function 'void setup()':
src/main.cpp:22:13: error: 'LED_BUILTIN' was not declared in this scope
pinMode(LED_BUILTIN, OUTPUT);解决方案
**重要:一些 ESP32 板如 ESP32-DevKitC 根本没有内置 LED!连接外部 LED 或找到另一种方法来做你想做的事情。
在大多数确实有内置 LED 的 ESP32 板上,LED 连接到引脚 2 - 然而,PlatformIO 不定义 LED_BUILTIN。为了修复此问题,自己定义 LED_BUILTIN,使用
define_led_builtin.cpp
#define LED_BUILTIN 2在你看到此错误的每个文件的顶部。
Check out similar posts by category:
Electronics, Embedded, ESP8266/ESP32, PlatformIO
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow