3
votes

I was trying to setup my first ESP32 board with Arduino IDE. It works fine with built-in LED but does not work with pins. Here is my code:

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
}

The on-board built-in LED is blinking according to my code but GPIO 25 is not outputting anything. I tried other pins and found none of them works. I happened to try GPIO 4 and found it blinking together with the built-in LED. It seems like GPIO 4 is connected to the built-in LED.

So did I miss anything setting up the pin mode or whatever? How can I select a pin and make it work as output to blink my LED on breadboard?

Thanks in advance.

1

1 Answers

3
votes
  1. Make sure Positive(+ive) terminal is connected to Pin 25 .
  2. Make sure, Pin number matched with pin name printed on board, there are different variants. If you select ESP32-DEV module and use pin layout in following link, most probably it will work. esp32-arduino-pin-layout
static const uint8_t A18 = 25;