RGB_BUILTIN - Should it actually be the Arduino pin for the RGB?
Posted: Tue Jun 27, 2023 3:10 pm
I have been experimenting with seeing if the Arduino debugger works with a few of the different ESP32 boards, and thought I would experiment with just cycling the colors of the built in RGB led... But each time I changed from (C3 to S2 or S3), I kept having to remember to change the #define for which pin to use for the LED (C3=8, S2=18, S3=48). I saw there is a define RGB_BUILTIN and sounded promising. But when I tried on a C3 the LED stopped working. I am using right now devkit-c3-m1...
So updated sketch to print out what pin does it think it is. Plus added code to first blink the LED_BUILTIN...
Code:
[Codebox]#include "Freenove_WS2812_Lib_for_ESP32.h"
#define LEDS_COUNT 1
#ifndef RGB_BUILTIN
#warning "RGB_BUILTIN was not defined"
#define RGB_BUILTIN 8
#endif
#define CHANNEL 0
Freenove_ESP32_WS2812 strip = Freenove_ESP32_WS2812(LEDS_COUNT, RGB_BUILTIN, CHANNEL, TYPE_GRB);
void setup() {
Serial.begin(115200);
while (!Serial && millis() < 5000);
Serial.print("LED Pin: "); Serial.println(LED_BUILTIN, DEC);
pinMode(LED_BUILTIN, OUTPUT);
for (uint8_t i = 0; i < 5; i++) {
digitalWrite(LED_BUILTIN, HIGH);
delay(500);
digitalWrite(LED_BUILTIN, LOW);
delay(500);
}
Serial.print("RGB PIN: "); Serial.println(RGB_BUILTIN, DEC);
strip.begin();
strip.setBrightness(20);
}
void loop() {
for (int j = 0; j < 255; j += 2) {
for (int i = 0; i < LEDS_COUNT; i++) {
strip.setLedColorData(i, strip.Wheel((i * 256 / LEDS_COUNT + j) & 255));
}
strip.show();
delay(10);
}
}
[/Codebox]
The Serial output:
[Codebox]mode:DIO, clock div:1
load:0x3fcd5810,len:0x438
load:0x403cc710,len:0x91c
load:0x403ce710,len:0x25b0
entry 0x403cc710
LED Pin: 30
RGB PIN: 30
E (5119) rmt: rmt_set_gpio(526): RMT GPIO ERROR
E (5119) rmt: rmt_config(686): set gpio for RMT driver failed
[/Codebox]
So both were defined as 30? The blink worked.
Suggestions?
Thanks
Kurt
So updated sketch to print out what pin does it think it is. Plus added code to first blink the LED_BUILTIN...
Code:
[Codebox]#include "Freenove_WS2812_Lib_for_ESP32.h"
#define LEDS_COUNT 1
#ifndef RGB_BUILTIN
#warning "RGB_BUILTIN was not defined"
#define RGB_BUILTIN 8
#endif
#define CHANNEL 0
Freenove_ESP32_WS2812 strip = Freenove_ESP32_WS2812(LEDS_COUNT, RGB_BUILTIN, CHANNEL, TYPE_GRB);
void setup() {
Serial.begin(115200);
while (!Serial && millis() < 5000);
Serial.print("LED Pin: "); Serial.println(LED_BUILTIN, DEC);
pinMode(LED_BUILTIN, OUTPUT);
for (uint8_t i = 0; i < 5; i++) {
digitalWrite(LED_BUILTIN, HIGH);
delay(500);
digitalWrite(LED_BUILTIN, LOW);
delay(500);
}
Serial.print("RGB PIN: "); Serial.println(RGB_BUILTIN, DEC);
strip.begin();
strip.setBrightness(20);
}
void loop() {
for (int j = 0; j < 255; j += 2) {
for (int i = 0; i < LEDS_COUNT; i++) {
strip.setLedColorData(i, strip.Wheel((i * 256 / LEDS_COUNT + j) & 255));
}
strip.show();
delay(10);
}
}
[/Codebox]
The Serial output:
[Codebox]mode:DIO, clock div:1
load:0x3fcd5810,len:0x438
load:0x403cc710,len:0x91c
load:0x403ce710,len:0x25b0
entry 0x403cc710
LED Pin: 30
RGB PIN: 30
E (5119) rmt: rmt_set_gpio(526): RMT GPIO ERROR
E (5119) rmt: rmt_config(686): set gpio for RMT driver failed
[/Codebox]
So both were defined as 30? The blink worked.
Suggestions?
Thanks
Kurt