3

我试图用 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?

提前致谢。

4

1 回答 1

3
  1. 确保正极(+ive)端子连接到引脚 25。
  2. 确保引脚编号与板上印制的引脚名称匹配,有不同的变体。如果您选择 ESP32-DEV 模块并使用以下链接中的引脚布局,很可能它会起作用。esp32-arduino-pin-layout
static const uint8_t A18 = 25;
于 2018-01-28T01:33:24.087 回答