rosvik / LiteStripe

Real time LED strip animation tool
MIT License
4 stars 0 forks source link

Make WS2812B controller #1

Open rosvik opened 5 years ago

rosvik commented 5 years ago
rosvik commented 5 years ago

Example from pololu/pololu-led-strip-arduino/examples/LedStripGradient that also have good documentation.

#include <PololuLedStrip.h>

// Create an ledStrip object and specify the pin it will use.
PololuLedStrip<12> ledStrip;

// Create a buffer for holding the colors (3 bytes per color).
#define LED_COUNT 60
rgb_color colors[LED_COUNT];

void setup() {}

void loop() {
  // Update the colors.
  byte time = millis() >> 2;
  for (uint16_t i = 0; i < LED_COUNT; i++) {
    byte x = time - 8*i;
    colors[i] = rgb_color(x, 255 - x, x);
  }

  // Write the colors to the LED strip.
  ledStrip.write(colors, LED_COUNT);

  delay(10);
}