5

I just bought an ESP32-C3-DevKitC-02 from Espressif, which features an onboard color LED. I'm a bit of a newbie in this space, so I thought I'd start by trying to get a simple "blink" program running. I've installed the Espressif VSCode extension, and I can successfully compile and load (flash) code. ...But the basic "blink" example doesn't blink the LED --- probably because the GPIO number is wrong. I did find a library for managing LEDs for this board, but it is generic and also accepts a GPIO as input, and running its sample code didn't work either. (Both the generic blink and the library samples specified GPIO 5 as the connection.)

Does anybody know what the right value is, or am I missing something else?

2
  • @jcaron --- thank you! Now that it is pointed out, I can see it printed on the board :-) Commented Jan 18, 2022 at 15:25
  • I got it working (yay!). It turns out there is an example that works for this: it is called led_strip, and it is in the peripherals/rmt subdirectory, which made it hard to find. It just happens to be an led_strip of length (1). Commented Jan 19, 2022 at 0:42

2 Answers 2

6

As stated in the page you linked to :) and as stencilled directly on the board, it’s connected to GPIO8.

Note that it’s an “addressable” RGB LED, so samples which just toggle an output won’t work, it needs to use a library for addressable LEDs. I suppose this is a WS2812 or equivalent, also known as a Neopixel in the Adafruit world, but I haven’t checked further.

0

If you are using an ESP32-S2-DevKitC-1, the RGB LED is on GPIO 18.

The following micropython code will set the rgb value for the LED:

from machine import Pin
from neopixel import NeoPixel

rgb = Pin(18,1)
np = NeoPixel(rgb,1)

np[0] = (255,0,0)      # sets blue=255, red=0, green=0
np.write()

Note the order is blue/red/green (not r/g/b). Setting values of 255 for the color parameters gives a very intense output. Values of 10 are much easier on the eyes.

Not the answer you're looking for? Browse other questions tagged or ask your own question.