Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. #include "FastLED.h"
  2.  
  3. // How many leds in your strip?
  4. #define NUM_LEDS 30
  5.  
  6. // For led chips like Neopixels, 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. #define DATA_PIN 4
  10. #define CLOCK_PIN 13
  11.  
  12. // Define the array of leds
  13. CRGB leds[NUM_LEDS];
  14.  
  15. void setup() {
  16. FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
  17. }
  18.  
  19. void loop() {
  20. // First slide the led in one direction
  21. for(int i = 0; i < NUM_LEDS; i++) {
  22. // Set the i'th led to red
  23. leds[i] = CRGB::Red;
  24. // Show the leds
  25. FastLED.show();
  26. // now that we've shown the leds, reset the i'th led to black
  27. leds[i] = CRGB::Black;
  28. // Wait a little bit before we loop around and do it again
  29. delay(90);
  30. }
  31.  
  32. // Now go in the other direction.
  33. for(int i = NUM_LEDS-1; i >= 0; i--) {
  34. // Set the i'th led to red
  35. leds[i] = CRGB::Red;
  36. // Show the leds
  37. FastLED.show();
  38. // now that we've shown the leds, reset the i'th led to black
  39. leds[i] = CRGB::Black;
  40. // Wait a little bit before we loop around and do it again
  41. delay(90);
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement