#include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "freertos/event_groups.h" #include "Arduino.h" #include "esp32-hal.h" // The effect seen in ESP32C3, ESP32S2 and ESP32S3 is like a Blink of RGB LED #if CONFIG_IDF_TARGET_ESP32S2 #define BUILTIN_RGBLED_PIN 18 #elif CONFIG_IDF_TARGET_ESP32S3 #define BUILTIN_RGBLED_PIN 48 #elif CONFIG_IDF_TARGET_ESP32C3 #define BUILTIN_RGBLED_PIN 8 #else #define BUILTIN_RGBLED_PIN 21 // ESP32 has no builtin RGB LED #endif #define NR_OF_LEDS 8*4 #define NR_OF_ALL_BITS 24*NR_OF_LEDS // // Note: This example uses Neopixel LED board, 32 LEDs chained one // after another, each RGB LED has its 24 bit value // for color configuration (8b for each color) // // Bits encoded as pulses as follows: // // "0": // +-------+ +-- // | | | // | | | // | | | // ---| |--------------| // + + + // | 0.4us | 0.85 0us | // // "1": // +-------------+ +-- // | | | // | | | // | | | // | | | // ---+ +-------+ // | 0.8us | 0.4us | rmt_data_t led_data[NR_OF_ALL_BITS]; rmt_obj_t* rmt_send = NULL; void setup() { Serial.begin(115200); if ((rmt_send = rmtInit(BUILTIN_RGBLED_PIN, RMT_TX_MODE, RMT_MEM_64)) == NULL) { Serial.println("init sender failed\n"); } float realTick = rmtSetTick(rmt_send, 100); Serial.printf("real tick set to: %fns\n", realTick); } int color[] = { 0x55, 0x11, 0x77 }; // RGB value int led_index = 0; void loop() { // Init data with only one led ON int led, col, bit; int i=0; for (led=0; led=NR_OF_LEDS) { led_index = 0; } // Send the data rmtWrite(rmt_send, led_data, NR_OF_ALL_BITS); delay(100); }