I just received my Arduino Nano ESP32 and wanted to tinker with the default sketch. I added the colors yellow, pink, turquoise and white to the sketch and uploaded it. Only the orange onboard LED started flashing. The RGB LED did nothing. So I deleted the lines for the built-in LED from the sketch to see if it was uploaded correctly and it worked. No blinking. So what was wrong... a few minutes later I found the article about the different pin numbering options in the IDE. I switched to GPIO numbering, uploaded again and it was working. But wait the colors are in the wrong order... so green and blue must be switched...
It is a bit confusing that the default sketch doesn't use the default pin numbering (Arduino). Also it is confusing that the numbering for LEDG(green) and LEDB(blue) are switched in the default sketch.
Maybe this should be changed in the Arduino Nano ESP 32 Cheat Sheet website.
Here is my altered code with the switched LEDG and LEDB pin numbers and all 7 colors.
Thank you. I only looked in the table of the "Nano ESP32 Selecting Pin Configuration"-guide which ends at D13. My post was meant as constructive criticism for the persons who manage the documentation as it is rather confusing for beginners. IMAO they should add D14, D15 and D16 to the predefined pin names list and change the default sketch accordingly so it will work with both configurations. Currently this sketch won't work because D14, D15 and D16 aren't defined.
@T-Error yes there is possibly a need for a re-write of the docs, for me that pin out diagram has been very useful, it's not the first pin out you come across so I think that sometimes it gets over looked.
look at the very last post in this thread
There is an option to choose between two different numbering schemes which I was unaware of but like I said I use the Nano with Micropython so it was not really affecting what I was doing.
@sumguy Yeah, I was referring to the guide which explains the different numbering schemes. There they recommend using the predefined labels " You can also control pins using labels such as
D1, D2, D3. These labels are predefined in the Board Package, and are adjusted based on what configuration you make.". But since D14, D15, D16 aren't predefined they won't work on any of both numbering scheme configurations.
The "Arduino ESP32 Boards" core defines pin macros for all four LEDs:
LED_RED
LED_GREEN
LED_BLUE
LED_BUILTIN
The core is configured to adjust the values of these macros so that they are always correct regardless of what you have selected from the Tools > Pin Numbering menu in Arduino IDE. So best practices is to use these macros to refer to the LED pins instead of defining redundant macros as was done in the sketch in the documentation.
The first limited production run of the Nano ESP32 used a different model of RGB LED than the subsequent runs (as noted here). The pin numbers in the sketch were correct for the boards of that first run, but incorrect for the far more numerous number of boards from the subsequent production runs. The LED_GREEN and LED_BLUE macros are correct for the boards from the subsequent production runs.
@ptillisch And again the Arduino team proves that they are simply awesome. Thank you for the quick response! The new sketch works flawlessly on both configurations.