Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. #include "FastLED.h"
  2. #define NUM_LEDS 16
  3. CRGB leds[NUM_LEDS];
  4. CRGB leds2[NUM_LEDS];
  5. #define PIN 6
  6. #define PIN2 7
  7.  
  8. void setup()
  9. {
  10. FastLED.addLeds<WS2811, PIN, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
  11. FastLED.addLeds<WS2811, PIN2, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
  12. FastLED.setBrightness(175);
  13. }
  14.  
  15. void loop()
  16. {
  17. for(int dot = -1; dot < NUM_LEDS; dot++)
  18. {
  19. leds[dot+2] = CRGB::White;
  20. FastLED.show();
  21. // clear this led for the next time around the loop
  22. leds[dot] = CRGB::Black;
  23. delay(75);
  24. }
  25. }
  26.  
  27. void showStrip()
  28. {
  29. #ifdef ADAFRUIT_NEOPIXEL_H
  30. // NeoPixel
  31. strip.show();
  32. #endif
  33. #ifndef ADAFRUIT_NEOPIXEL_H
  34. // FastLED
  35. FastLED.show();
  36. #endif
  37. }
  38.  
  39. void setPixel(int Pixel, byte red, byte green, byte blue)
  40. {
  41. #ifdef ADAFRUIT_NEOPIXEL_H
  42. // NeoPixel
  43. strip.setPixelColor(Pixel, strip.Color(red, green, blue));
  44. #endif
  45. #ifndef ADAFRUIT_NEOPIXEL_H
  46. // FastLED
  47. leds[Pixel].r = red;
  48. leds[Pixel].g = green;
  49. leds[Pixel].b = blue;
  50. #endif
  51. }
  52.  
  53. void setAll(byte red, byte green, byte blue)
  54. {
  55. for(int i = 0; i < NUM_LEDS; i++ )
  56. {
  57. setPixel(i, red, green, blue);
  58. }
  59. showStrip();
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement