Test code for 8 Neopixel/WS2812B LEDs
This test code toggles 8 WS2812b LEDs with circulating colors and will test all three R/G/B LEDs in each LED plus their connection.. It is based on an ESP32 with a 74LV245 level shifter, but it will also work on other platforms supported by NeoPixelBus. In my configuration, the 3.3V signal output pin is on pin 13.
#include <NeoPixelBus.h>
#include <NeoPixelAnimator.h>
const uint16_t PixelCount = 8;
const uint8_t PixelPin = 13;
NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);
void DrawPixels(uint32_t offset)
{
strip.SetPixelColor((0 + offset) % 8, RgbColor(255, 0, 0));
strip.SetPixelColor((1 + offset) % 8, RgbColor(0, 255, 0));
strip.SetPixelColor((2 + offset) % 8, RgbColor(0, 0, 255));
strip.SetPixelColor((3 + offset) % 8, RgbColor(255, 255, 0));
strip.SetPixelColor((4 + offset) % 8, RgbColor(0, 255, 255));
strip.SetPixelColor((5 + offset) % 8, RgbColor(255, 0, 255));
strip.SetPixelColor((6 + offset) % 8, RgbColor(255, 255, 255));
strip.SetPixelColor((7 + offset) % 8, RgbColor(0, 0, 0));
strip.Show();
}
void setup()
{
strip.Begin();
strip.Show();
}
uint32_t loopCounter = 0;
void loop()
{
DrawPixels(loopCounter);
loopCounter++;
delay(250);
}
PlatformIO config:
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:nodemcu-32s]
platform = espressif32
board = nodemcu-32s
framework = arduino
lib_deps =
makuna/NeoPixelBus @ ^2.6.9