Guest User

Untitled

a guest
Nov 5th, 2023
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. #include <FastLED.h>
  3.  
  4. #define LED_TYPE    APA102
  5. #define COLOR_ORDER RGB
  6. #define NUM_LEDS    66
  7. #define BRIGHTNESS  255
  8. // Define the array of leds
  9. CRGB leds[NUM_LEDS];
  10.  
  11. void setup() {
  12.  delay(3000); // 3 second delay for recovery
  13.  
  14.   // tell FastLED about the LED strip configuration
  15.   FastLED.addLeds<LED_TYPE, COLOR_ORDER>(leds, NUM_LEDS)
  16.     .setCorrection(TypicalLEDStrip)
  17.     .setDither(BRIGHTNESS < 255);
  18.  
  19.   // set master brightness control
  20.   FastLED.setBrightness(BRIGHTNESS);
  21. }
  22.  
  23.  
  24. void loop()
  25. {
  26.   pride();
  27.   FastLED.show();  
  28. }
  29.  
  30.  
  31. // This function draws rainbows with an ever-changing,
  32. // widely-varying set of parameters.
  33. void pride()
  34. {
  35.   static uint16_t sPseudotime = 0;
  36.   static uint16_t sLastMillis = 0;
  37.   static uint16_t sHue16 = 0;
  38.  
  39.   uint8_t sat8 = beatsin88( 87, 220, 250);
  40.   uint8_t brightdepth = beatsin88( 341, 96, 224);
  41.   uint16_t brightnessthetainc16 = beatsin88( 203, (25 * 256), (40 * 256));
  42.   uint8_t msmultiplier = beatsin88(147, 23, 60);
  43.  
  44.   uint16_t hue16 = sHue16;//gHue * 256;
  45.   uint16_t hueinc16 = beatsin88(113, 1, 3000);
  46.  
  47.   uint16_t ms = millis();
  48.   uint16_t deltams = ms - sLastMillis ;
  49.   sLastMillis  = ms;
  50.   sPseudotime += deltams * msmultiplier;
  51.   sHue16 += deltams * beatsin88( 400, 5,9);
  52.   uint16_t brightnesstheta16 = sPseudotime;
  53.  
  54.   for( uint16_t i = 0 ; i < NUM_LEDS; i++) {
  55.     hue16 += hueinc16;
  56.     uint8_t hue8 = hue16 / 256;
  57.  
  58.     brightnesstheta16  += brightnessthetainc16;
  59.     uint16_t b16 = sin16( brightnesstheta16  ) + 32768;
  60.  
  61.     uint16_t bri16 = (uint32_t)((uint32_t)b16 * (uint32_t)b16) / 65536;
  62.     uint8_t bri8 = (uint32_t)(((uint32_t)bri16) * brightdepth) / 65536;
  63.     bri8 += (255 - brightdepth);
  64.    
  65.     CRGB newcolor = CHSV( hue8, sat8, bri8);
  66.    
  67.     uint16_t pixelnumber = i;
  68.     pixelnumber = (NUM_LEDS-1) - pixelnumber;
  69.    
  70.     nblend( leds[pixelnumber], newcolor, 64);
  71.   }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment