Skip to content

Commit 286bfec

Browse files
committed
Correct pin numbers for Nano ESP32 LED
Arduino pin numbers are an arbitrary numerical identifier for the I/O pins on the microcontroller. They are mapped to the lower level identifier in the board's core variant. Generally, Arduino functions that take a pin number argument require that argument to be an Arduino pin number rather than some lower level identifier for the pin, and that is the case with the Arduino core functions for the Nano ESP32 board. Previously, the documentation of the pins connected to the RGB LED on the Nano ESP32 board used the lower level ESP32 GPIO pin numbers in the digitalWrite calls in the code snippet. Since digitalWrite requires the use of an Arduino pin number, not a GPIO number, that code was wrong and did not control the RGB LED as claimed. When correcting this error, I chose to use the human friendly constants rather than the bare integer literals (14, 15, 16).
1 parent a1db178 commit 286bfec

File tree

1 file changed

+4
-4
lines changed
  • content/hardware/03.nano/boards/nano-esp32/tutorials/cheat-sheet

1 file changed

+4
-4
lines changed

content/hardware/03.nano/boards/nano-esp32/tutorials/cheat-sheet/cheat-sheet.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,16 +346,16 @@ There are several examples provided bundled with the core that showcase how to m
346346

347347
## RGB
348348

349-
The ESP32 features an RGB that can be controlled with the `0`, `45` and `46` GPIO. These are not connected to any physical pins.
349+
The ESP32 features an RGB that can be controlled with the `LED_RED`, `LED_GREEN` and `LED_BLUE` pins. These are not connected to any physical pins.
350350

351351
***Some boards from the first limited production batch were assembled with a different RGB LED which has the green and blue pins inverted. Read our full Help Center article [here](https://support.arduino.cc/hc/en-us/articles/9589073738012)***
352352

353353
To control them, use:
354354

355355
```arduino
356-
digitalWrite(46, STATE); //red
357-
digitalWrite(45, STATE); //green
358-
digitalWrite(0, STATE); //blue
356+
digitalWrite(LED_RED, STATE); //red
357+
digitalWrite(LED_GREEN, STATE); //green
358+
digitalWrite(LED_BLUE, STATE); //blue
359359
```
360360

361361

0 commit comments

Comments
 (0)