Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <FastLED.h>
- #include <neotimer.h>
- #define COOLING 55
- #define SPARKING 120
- #define LED_PIN 2
- #define COLOR_ORDER GRB
- #define CHIPSET WS2812B
- #define BRIGHTNESS 160
- #define NUM_LEDS 35
- int Brennweite = 35;
- Neotimer Time1 = Neotimer(4000);
- Neotimer Time2 = Neotimer(7000);
- #define FRAMES_PER_SECOND 60
- bool gReverseDirection = true;
- CRGBPalette16 gPal;
- CRGBPalette16 gPal2;
- CRGB leds[NUM_LEDS];
- void setup()
- {
- //Serial.begin(9600);
- //delay(3000); // sanity delay
- FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
- FastLED.setBrightness(BRIGHTNESS );
- gPal = CRGBPalette16( CRGB::Black, CRGB::Blue, CRGB::Aqua, CRGB::White);
- Time1.start();
- Time2.start();
- }
- void loop()
- {
- random16_add_entropy( random());
- Fire2012(); // run simulation frame
- FastLED.show(); // display this frame
- FastLED.delay(1000/ FRAMES_PER_SECOND);
- if(Time1.done())
- {
- Fadeout (Brennweite, 1);
- Time1.stop();
- }
- }
- void Fire2012()
- {
- static byte heat[NUM_LEDS];
- for( int i = 0; i < Brennweite; i++)
- {
- heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / Brennweite) + 2));
- }
- for( int k= Brennweite - 1; k >= 2; k--)
- {
- heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3;
- }
- if( random8() < SPARKING )
- {
- int y = random8(7);
- heat[y] = qadd8( heat[y], random8(160,255) );
- }
- for( int j = 0; j < Brennweite; j++)
- {
- byte colorindex = scale8( heat[j], 240);
- CRGB color = ColorFromPalette( gPal, colorindex);
- int pixelnumber;
- if( gReverseDirection )
- {
- pixelnumber = (Brennweite-1) - j;
- }
- else
- {
- pixelnumber = j;
- }
- leds[pixelnumber] = color;
- }
- }
- void Fadeout(int Brennweite, int fadespeed)
- {
- for (int a = Brennweite; a =1; Brennweite--)
- {
- Brennweite = Brennweite - fadespeed;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement