我试图用Arduino IDE设置我的第一块ESP32板。它内置LED工作正常,但不适用于引脚。这是我的代码:
int LED_BUILTIN = 2; // works fine
int LED_OUT = 25; // not working, even other pins
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
pinMode(LED_OUT, OUTPUT);
Serial.begin(115200);
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH);
// turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW);
// turn the LED off by making the voltage LOW
delay(1000); // wait for a second
digitalWrite(LED_OUT, HIGH);
// turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_OUT, LOW);
// turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
根据我的代码,板载内置LED闪烁,但GPIO 25没有输出任何东西。我尝试了其他针脚,发现它们都不起作用。我碰巧尝试了GPIO 4,发现它与内置LED一起闪烁。看起来GPIO 4连接到内置LED。
所以,我错过任何设置引脚模式或其他什么?如何选择一个引脚并使其作为输出工作以使我在面包板上的LED闪烁?
提前致谢。
答案 0 :(得分:2)
static const uint8_t A18 = 25;