Advertisement
TopHatRaver

SimpleFastLED

Mar 1st, 2024
880
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /// @file    DemoReel100.ino
  2. /// @brief   FastLED "100 lines of code" demo reel, showing off some effects
  3. /// @example DemoReel100.ino
  4.  
  5. #include <FastLED.h>
  6.  
  7. FASTLED_USING_NAMESPACE
  8.  
  9. // FastLED "100-lines-of-code" demo reel, showing just a few
  10. // of the kinds of animation patterns you can quickly and easily
  11. // compose using FastLED.  
  12. //
  13. // This example also shows one easy way to define multiple
  14. // animations patterns and have them automatically rotate.
  15. //
  16. // -Mark Kriegsman, December 2014
  17.  
  18.  
  19. #define DATA_PIN    1
  20. //#define CLK_PIN   4
  21. #define LED_TYPE    WS2812
  22. #define COLOR_ORDER GRB
  23. #define NUM_LEDS    96
  24. CRGB leds[NUM_LEDS];
  25.  
  26. #define BRIGHTNESS          96
  27. #define FRAMES_PER_SECOND  120
  28.  
  29. void setup() {
  30.   delay(3000); // 3 second delay for recovery
  31.  
  32.   // tell FastLED about the LED strip configuration
  33.   FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  34.   //FastLED.addLeds<LED_TYPE,DATA_PIN,CLK_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  35.  
  36.   // set master brightness control
  37.   FastLED.setBrightness(BRIGHTNESS);
  38. }
  39.  
  40.  
  41. // List of patterns to cycle through.  Each is defined as a separate function below.
  42. typedef void (*SimplePatternList[])();
  43. SimplePatternList gPatterns = { fillsolid }; //rainbow, rainbowWithGlitter, confetti, sinelon, juggle, bpm };
  44.  
  45. uint8_t gCurrentPatternNumber = 0; // Index number of which pattern is current
  46. uint8_t gHue = 0; // rotating "base color" used by many of the patterns
  47.  
  48. void loop()
  49. {
  50.   // Call the current pattern function once, updating the 'leds' array
  51.   fillsolid();
  52.  
  53.   // send the 'leds' array out to the actual LED strip
  54.   FastLED.show();  
  55.   // insert a delay to keep the framerate modest
  56.   FastLED.delay(1000/FRAMES_PER_SECOND);
  57.  
  58.   // do some periodic updates
  59.   EVERY_N_MILLISECONDS( 20 ) { gHue++; } // slowly cycle the "base color" through the rainbow
  60.  
  61. }
  62.  
  63.  
  64. void fillsolid(){
  65.   for (int x = 0 ; x < 12; x++){
  66.     leds[x] = CHSV(255,255,255);
  67.   }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement