Advertisement
CaptainSpaceCat

WS2811 LED Strip Issues

Jan 7th, 2022
1,403
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.93 KB | None | 0 0
  1. #include <FastLED.h>
  2.  
  3. // How many leds in your strip?
  4. #define NUM_LEDS 50
  5.  
  6. // For led chips like WS2812, which have a data line, ground, and power, you just
  7. // need to define DATA_PIN.  For led chipsets that are SPI based (four wires - data, clock,
  8. // ground, and power), like the LPD8806 define both DATA_PIN and CLOCK_PIN
  9. // Clock pin only needed for SPI based chipsets when not using hardware SPI
  10. #define DATA_PIN 6
  11. #define CLOCK_PIN 13
  12.  
  13. // Define the array of leds
  14. CRGB leds[NUM_LEDS];
  15.  
  16. void setup() {
  17.     FastLED.addLeds<WS2811, DATA_PIN, BRG>(leds, NUM_LEDS);
  18.     //the amazon page specifies that these ICs expect data in BRG format, though I've tried to run the code with other formats too with the same result
  19. }
  20.  
  21. void loop() {
  22.   // Turn the LED on, then pause
  23.   leds[0] = CRGB::Red;
  24.   FastLED.show();
  25.   delay(500);
  26.   // Now turn the LED off, then pause
  27.   leds[0] = CRGB::Black;
  28.   FastLED.show();
  29.   delay(500);
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement