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
RGB_BUILTIN - Should it actually be the Arduino pin for the RGB?
Re: RGB_BUILTIN - Should it actually be the Arduino pin for the RGB?
Quick update: Looking through the open issues, I found some of the information in https://github.com/espressif/arduino-esp32/issues/7767
RGB_BUILTIN works fine with the function: neopixelWrite
I also found that if I run the sketch:
on an S2 or S3
The code would Guru meditate:
When : bool Freenove_ESP32_WS2812::begin()
called: if ((rmt_send = rmtInit(pin, true, rmt_mem)) == NULL){
with pin number 97
And faulted in the call to rmt_config
So for now with my experiments I will use the neopixelWrite.
RGB_BUILTIN works fine with the function: neopixelWrite
I also found that if I run the sketch:
Code: Select all
#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);
Serial.flush();
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);
}
}
The code would Guru meditate:
When : bool Freenove_ESP32_WS2812::begin()
called: if ((rmt_send = rmtInit(pin, true, rmt_mem)) == NULL){
with pin number 97
And faulted in the call to rmt_config
Code: Select all
if (tx_not_rx) {
rmt_config_t config = RMT_DEFAULT_ARD_CONFIG_TX(pin, channel, buffers);
esp_err_code = rmt_config(&config);
-
- Posts: 826
- Joined: Mon Jul 22, 2019 3:20 pm
Re: RGB_BUILTIN - Should it actually be the Arduino pin for the RGB?
I'm not sure I love how this was implemented, but RGB_BUILTIN has co-opted the previous use of LED_BUILTIN, specifically to make it easier to use the Arduino HIGH/LOW functionality. The code for neoPixelWrite is part of arduino-esp32 core- RGB_BUILTIN is not going to work as an RGB with any 3rd party libraries.
https://github.com/espressif/arduino-es ... .h#L11-L14
https://github.com/espressif/arduino-es ... -led.c#L12
https://github.com/espressif/arduino-es ... .h#L11-L14
https://github.com/espressif/arduino-es ... -led.c#L12
Re: RGB_BUILTIN - Should it actually be the Arduino pin for the RGB?
Thanks, I agree I am not sure I like it either, but library or sketch code might be able tolbernstone wrote: ↑Wed Jun 28, 2023 6:53 pmI'm not sure I love how this was implemented, but RGB_BUILTIN has co-opted the previous use of LED_BUILTIN, specifically to make it easier to use the Arduino HIGH/LOW functionality. The code for neoPixelWrite is part of arduino-esp32 core- RGB_BUILTIN is not going to work as an RGB with any 3rd party libraries.
https://github.com/espressif/arduino-es ... .h#L11-L14
https://github.com/espressif/arduino-es ... -led.c#L12
use the hack code:
Code: Select all
#ifdef RGB_BUILTIN
if(pin == RGB_BUILTIN){
_pin = RGB_BUILTIN-SOC_GPIO_PIN_COUNT;
}
#endif
Thanks again
Who is online
Users browsing this forum: No registered users and 59 guests