Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <FastLED.h>
  2. #include <neotimer.h>
  3. #define COOLING 55
  4. #define SPARKING 120
  5. #define LED_PIN 2
  6. #define COLOR_ORDER GRB
  7. #define CHIPSET WS2812B
  8. #define BRIGHTNESS 160
  9. #define NUM_LEDS 35
  10.  
  11. int Brennweite = 35;
  12.  
  13. Neotimer Time1 = Neotimer(4000);
  14. Neotimer Time2 = Neotimer(7000);
  15.  
  16. #define FRAMES_PER_SECOND 60
  17.  
  18. bool gReverseDirection = true;
  19. CRGBPalette16 gPal;
  20. CRGBPalette16 gPal2;
  21. CRGB leds[NUM_LEDS];
  22.  
  23. void setup()
  24. {
  25.     //Serial.begin(9600);
  26.     //delay(3000); // sanity delay
  27.     FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
  28.     FastLED.setBrightness(BRIGHTNESS );
  29.     gPal = CRGBPalette16( CRGB::Black, CRGB::Blue, CRGB::Aqua, CRGB::White);
  30.     Time1.start();
  31.     Time2.start();
  32. }
  33.  
  34. void loop()
  35. {
  36.     random16_add_entropy( random());
  37.  
  38.     Fire2012(); // run simulation frame
  39.  
  40.     FastLED.show(); // display this frame
  41.     FastLED.delay(1000/ FRAMES_PER_SECOND);
  42.    
  43.     if(Time1.done())
  44.         {
  45.             Fadeout (Brennweite, 1);
  46.             Time1.stop();
  47.         }
  48. }
  49.  
  50. void Fire2012()
  51. {
  52.     static byte heat[NUM_LEDS];
  53.  
  54.     for( int i = 0; i < Brennweite; i++)
  55.     {
  56.     heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / Brennweite) + 2));
  57.     }
  58.    
  59.     for( int k= Brennweite - 1; k >= 2; k--)
  60.     {
  61.         heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3;
  62.     }
  63.    
  64.     if( random8() < SPARKING )
  65.     {
  66.         int y = random8(7);
  67.         heat[y] = qadd8( heat[y], random8(160,255) );
  68.     }
  69.  
  70.     for( int j = 0; j < Brennweite; j++)
  71.     {
  72.         byte colorindex = scale8( heat[j], 240);
  73.         CRGB color = ColorFromPalette( gPal, colorindex);
  74.         int pixelnumber;
  75.        
  76.         if( gReverseDirection )
  77.         {
  78.             pixelnumber = (Brennweite-1) - j;
  79.         }
  80.         else
  81.         {
  82.             pixelnumber = j;
  83.         }
  84.        
  85.         leds[pixelnumber] = color;
  86.     }
  87. }
  88.  
  89. void Fadeout(int Brennweite, int fadespeed)
  90. {
  91.     for (int a = Brennweite; a =1; Brennweite--)
  92.     {
  93.         Brennweite = Brennweite - fadespeed;
  94.     }
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement