LEDPROJECT69420

Untitled

Aug 12th, 2020
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 KB | None | 0 0
  1.  
  2. #include <FastLED.h>
  3.  
  4. // Move a white dot along the strip of leds.  This program simply shows how to configure the leds,
  5. // and then how to turn a single pixel white and then off, moving down the line of pixels.
  6. #define NUM_LEDS 300
  7.  
  8. #define DATA_PIN 5
  9.  
  10. // This is an array of leds.  One item for each led in your strip.
  11. CRGB leds[NUM_LEDS];
  12.  
  13. void setup() {
  14.     delay(2000);
  15.     FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);  // GRB ordering is typical
  16.    
  17. void loop() {
  18.    // Move a single white led
  19.    for(int whiteLed = 0; whiteLed < NUM_LEDS; whiteLed = whiteLed + 1) {
  20.       // Turn our current led on to white, then show the leds
  21.       leds[whiteLed] = CRGB::White;
  22.  
  23.       // Show the leds (only one of which is set to white, from above)
  24.       FastLED.show();
  25.  
  26.       // Wait a little bit
  27.       delay(100);
  28.  
  29.       // Turn our current led back to black for the next loop around
  30.       leds[whiteLed] = CRGB::Black;
  31.    }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment