This is an Arduino library for controlling ws2812b led on esp32. Please note that our library supports ESP32 package versions up to 3.0.0. Based on the example program "led_strip" in IDF-SDK. The source code repository is here: https://github.com/espressif/esp-idf/tree/master/examples/peripherals/rmt/led_strip
Here are some simple examples.
This example make your strip show a flowing rainbow.
#include "Freenove_WS2812_Lib_for_ESP32.h"
#define LEDS_COUNT 8
#define LEDS_PIN 2
#define CHANNEL 0
Freenove_ESP32_WS2812 strip = Freenove_ESP32_WS2812(LEDS_COUNT, LEDS_PIN, CHANNEL);
void setup() {
strip.begin();
}
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(2);
}
}
Freenove_ESP32_WS2812 strip = Freenove_ESP32_WS2812(LEDS_COUNT, LEDS_PIN, CHANNEL, TYPE_GRB);
strip.begin()
Initialization data, ready for communication.
strip.setLedColorData(id, color);
strip.setLedColorData(id, r, g, b);
strip.show();
strip.setLedColor(id, color);
strip.setLedColor(id, r, g, b);
strip.Wheel(i)