#include <FastLED.h>
#define LED_OUT 3
#define LED_PIN 9
#define LED_Pin 6
#define COLOR_ORDER BGR
#define CHIPSET WS2811
#define NUM_LEDS 50
#define BRIGHTNESS 30
#define FRAMES_PER_SECOND 10
CRGB leds[NUM_LEDS];
void setup() {
delay(3000); // sanity delay
FastLED.addLeds<CHIPSET, LED_PIN , COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.addLeds<CHIPSET, LED_OUT, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.addLeds<CHIPSET, LED_Pin, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.setBrightness( BRIGHTNESS );
}
void loop()
{
random16_add_entropy( random());
Fire2012(); // run simulation frame
FastLED.show(); // display this frame
FastLED.delay(500/ FRAMES_PER_SECOND);
SnowSparkle(0x10, 0x10, 0x10, 20, random(100,1000));
}
#define COOLING 55
#define SPARKING 120
void Fire2012()
{
// Array of temperature readings at each simulation cell
static byte heat[NUM_LEDS];
// Step 1. Cool down every cell a little
for( int i = 0; i < NUM_LEDS; i++) {
heat = qsub8( heat, random8(0, ((COOLING * 10) / NUM_LEDS) + 2));
* }*
* // Step 2. Heat from each cell drifts 'up' and diffuses a little*
* for( int k= NUM_LEDS - 1; k >= 2; k--) {
_ heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3;_
_ }*_
* // Step 3. Randomly ignite new 'sparks' of heat near the bottom*
* if( random8() < SPARKING ) {*
* int y = random8(7);*
* heat[y] = qadd8( heat[y], random8(160,255) );*
* }*
* // Step 4. Map from heat cells to LED colors*
* for( int j = 0; j < NUM_LEDS; j++) {
_ leds[j] = HeatColor( heat[j]);*_
* }*
}
void SnowSparkle(byte red, byte green, byte blue, int SparkleDelay, int SpeedDelay) {
* setAll(red,green,blue);*
* int Pixel = random(NUM_LEDS);
_ setPixel(Pixel,0xff,0xff,0xff);_
_ showStrip();_
_ delay(SparkleDelay);_
_ setPixel(Pixel,red,green,blue);_
_ showStrip();_
_ delay(SpeedDelay);_
_}_
void showStrip() {
#ifdef ADAFRUIT_NEOPIXEL_H*
* // NeoPixel*
* strip.show();*
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
* // FastLED*
* FastLED.show();*
#endif
}
void setPixel(int Pixel, byte red, byte green, byte blue) {
#ifdef ADAFRUIT_NEOPIXEL_H
* // NeoPixel*
* strip.setPixelColor(Pixel, strip.Color(red, green, blue));*
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
* // FastLED*
* leds[Pixel].r = red;*
* leds[Pixel].g = green;*
* leds[Pixel].b = blue;*
#endif
}
void setAll(byte red, byte green, byte blue) {
* for(int i = 0; i < NUM_LEDS; i++ ) {
_ setPixel(i, red, green, blue);_
_ }_
_ showStrip();_
_}*_