Advertisement
Guest User

Untitled

a guest
Nov 27th, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.41 KB | None | 0 0
  1. // Use if you want to force the software SPI subsystem to be used for some reason (generally, you don't)
  2. // #define FASTLED_FORCE_SOFTWARE_SPI
  3. // Use if you want to force non-accelerated pin access (hint: you really don't, it breaks lots of things)
  4. // #define FASTLED_FORCE_SOFTWARE_SPI
  5. // #define FASTLED_FORCE_SOFTWARE_PINS
  6. #include <FastLED.h>
  7.  
  8. ///////////////////////////////////////////////////////////////////////////////////////////
  9. //
  10. // Move a white dot along the strip of leds. This program simply shows how to configure the leds,
  11. // and then how to turn a single pixel white and then off, moving down the line of pixels.
  12. //
  13.  
  14. // How many leds are in the strip?
  15. #define NUM_LEDS 60
  16.  
  17. // Data pin that led data will be written out over
  18. #define DATA_PIN 3
  19.  
  20. // Clock pin only needed for SPI based chipsets when not using hardware SPI
  21. //#define CLOCK_PIN 8
  22.  
  23. // This is an array of leds. One item for each led in your strip.
  24. CRGB leds[NUM_LEDS];
  25.  
  26. // This function sets up the ledsand tells the controller about them
  27. void setup() {
  28. // sanity check delay - allows reprogramming if accidently blowing power w/leds
  29. delay(2000);
  30.  
  31. // Uncomment one of the following lines for your leds arrangement.
  32. // FastLED.addLeds<TM1803, DATA_PIN, RGB>(leds, NUM_LEDS);
  33. // FastLED.addLeds<TM1804, DATA_PIN, RGB>(leds, NUM_LEDS);
  34. // FastLED.addLeds<TM1809, DATA_PIN, RGB>(leds, NUM_LEDS);
  35. FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);
  36. // FastLED.addLeds<WS2812, DATA_PIN, RGB>(leds, NUM_LEDS);
  37. // FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);
  38. // FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
  39. // FastLED.addLeds<APA104, DATA_PIN>(leds, NUM_LEDS);
  40. // FastLED.addLeds<WS2811_400, DATA_PIN, RGB>(leds, NUM_LEDS);
  41. // FastLED.addLeds<GW6205, DATA_PIN, RGB>(leds, NUM_LEDS);
  42. // FastLED.addLeds<GW6205_400, DATA_PIN, RGB>(leds, NUM_LEDS);
  43. // FastLED.addLeds<UCS1903, DATA_PIN, RGB>(leds, NUM_LEDS);
  44. // FastLED.addLeds<UCS1903B, DATA_PIN, RGB>(leds, NUM_LEDS);
  45.  
  46. // FastLED.addLeds<WS2801, RGB>(leds, NUM_LEDS);
  47. // FastLED.addLeds<SM16716, RGB>(leds, NUM_LEDS);
  48. // FastLED.addLeds<LPD8806, RGB>(leds, NUM_LEDS);
  49. // FastLED.addLeds<P9813, RGB>(leds, NUM_LEDS);
  50. // FastLED.addLeds<APA102, RGB>(leds, NUM_LEDS);
  51. // FastLED.addLeds<DOTSTAR, RGB>(leds, NUM_LEDS);
  52.  
  53. // FastLED.addLeds<WS2801, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
  54. // FastLED.addLeds<SM16716, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
  55. // FastLED.addLeds<LPD8806, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
  56. // FastLED.addLeds<P9813, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
  57. // FastLED.addLeds<APA102, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
  58. // FastLED.addLeds<DOTSTAR, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
  59. }
  60.  
  61. // This function runs over and over, and is where you do the magic to light
  62. // your leds.
  63. void loop() {
  64. // Move a single white led
  65. for(int whiteLed = 0; whiteLed < NUM_LEDS; whiteLed = whiteLed + 1) {
  66. // Turn our current led on to white, then show the leds
  67. leds[whiteLed] = CRGB::White;
  68.  
  69. // Show the leds (only one of which is set to white, from above)
  70. FastLED.show();
  71.  
  72. // Wait a little bit
  73. delay(100);
  74.  
  75. // Turn our current led back to black for the next loop around
  76. leds[whiteLed] = CRGB::Black;
  77. }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement