HighInBC

WS2812B example

Jan 19th, 2017
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <Adafruit_NeoPixel.h>
  2. #ifdef __AVR__
  3.   #include <avr/power.h>
  4. #endif
  5.  
  6. #define PIN 10
  7. Adafruit_NeoPixel strip = Adafruit_NeoPixel(25, PIN, NEO_GRB + NEO_KHZ800);
  8. uint32_t RED   = strip.Color( 255, 0,   0   );
  9. uint32_t BLUE  = strip.Color( 0,   0,   255 );
  10. uint32_t WHITE = strip.Color( 255, 255, 255 );
  11. uint32_t LEDColours[25] = {
  12.   RED, RED, RED,
  13.   RED, RED, RED,
  14.   WHITE, WHITE, WHITE,
  15.   WHITE, WHITE, WHITE,
  16.   WHITE, WHITE, WHITE,
  17.   WHITE, WHITE, WHITE,
  18.   RED, RED, RED,
  19.   RED, RED, RED,
  20.   BLUE
  21. };
  22.  
  23. void setup() {
  24.   strip.begin();
  25.   strip.show();
  26.   for(uint16_t i=0; i<strip.numPixels(); i++) {
  27.     strip.setPixelColor(i, LEDColours[i]);
  28.     strip.show();
  29.   }
  30. }
  31.  
  32. void loop() {
  33. }
Advertisement
Add Comment
Please, Sign In to add comment