//fire2021_____________________________________
// Perlin noise fire procedure
// 8x8 rgb led matrix demo
// Yaroslaw Turbin, 22.06.2020
//https://vk.com/ldirko
//https://www.reddit.com/user/ldirko/
//https://twitter.com/ldir_ko
//https://www.youtube.com/c/ldirldir
// https://www.reddit.com/r/FastLED/comments/hgu16i/my_fire_effect_implementation_based_on_perlin/
#include <FastLED.h>
#define DATA_PIN 3
#define LED_TYPE WS2812B //leds type
#define COLOR_ORDER GRB //color order of leds
#define MAX_POWER_MILLIAMPS 700 //write here your power in milliamps. default i set 800 mA for safet
#define NUM_COLS 8 // resolution of planar lookup table
#define NUM_ROWS 8 // resolution of planar lookup table
#define NUM_LEDS NUM_COLS*NUM_ROWS
byte brigtness = 255;
CRGB leds [NUM_LEDS];
void setup() {
FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);
FastLED.setBrightness(brigtness);
//uncomment this before upload sketch
// FastLED.setMaxPowerInVoltsAndMilliamps(5, MAX_POWER_MILLIAMPS);
FastLED.clear();
}
const byte PlanarTable [] PROGMEM = {
0, 1, 2, 3, 4, 5, 6, 7,
15, 14, 13, 12, 11, 10, 9, 8,
16, 17, 18, 19, 20, 21, 22, 23,
31, 30, 29, 28, 27, 26, 25, 24,
32, 33, 34, 35, 36, 37, 38, 39,
47, 46, 45, 44, 43, 42, 41, 40,
48, 49, 50, 51, 52, 53, 54, 55,
63, 62, 61, 60, 59, 58, 57, 56
};
byte XY(byte x, byte y) { // calculate index in leds from XY coordinates for planar mapping
uint16_t ledsindex = pgm_read_byte (PlanarTable+y*NUM_COLS+x);
return (ledsindex);
}
void fire2021 (){
int a = millis();
int a1 = a/3;
for (byte j = 0; j < NUM_ROWS; j++) {
for (byte i = 0; i < NUM_COLS; i++) {
int ledsindex = XY(i, j);
leds[ledsindex] = HeatColor(qsub8 (inoise8 (i * 80, j * 80+a, a1),
abs8(j - (NUM_ROWS-1)) * 255 / (NUM_ROWS+4)));
}
}
}
void loop() {
fire2021 ();
FastLED.show();
delay(2);
}
FPS: 0
Power: 0.00W
Power: 0.00W