8x8 WS2812b Animated Fire Effect

by wilsnico in Circuits > Arduino

9 Views, 0 Favorites, 0 Comments

8x8 WS2812b Animated Fire Effect

1000028520.jpg
1000028521.jpg

Fire effect for 8x8 matrix.

Supplies

Resistor 4.75k ohm

Jumper wires (generic)

Arduino UNO

Or another Arduino version

Adafruit NeoPixel NeoMatrix 8x8 - 64 RGB LED Pixel Matrix

Or another WS2812B 8x8 matrix .

Info

Burning fire effect for 8x8 ws2812b matrix.

Code is in void and void is called in loop.

Connection Resistor to Matrix on PIN 5.

Updated 1/2/2025

video effect :

https://drive.google.com/file/d/1-ZfdPW3X7HGP10dNuqEoAw3eCXKlVGD-/view


Code

#include "Adafruit_NeoPixel.h"

#include "Adafruit_GFX.h"

#define WS2812b_PIN 5

#define WS2812b_PIXELS 64

#define WS2812b_WIDTH 8

#define WS2812b_HEIGHT 8

Adafruit_NeoPixel WS2812b = Adafruit_NeoPixel(WS2812b_PIXELS,

WS2812b_PIN, NEO_GRB + NEO_KHZ800);


void setup() {

Serial.begin(9600);

WS2812b.begin();

WS2812b.clear();

WS2812b.show();

}


void drawFire() {

WS2812b.setBrightness(75);

for (int y = 0; y < WS2812b_HEIGHT; y++) {

for (int x = 0; x < WS2812b_WIDTH; x++) {

int index = y * WS2812b_WIDTH + x;

int red, green = 25, blue = 0;

if (y == 0) {

red = random(150, 255);

} else if (y < (1 * WS2812b_HEIGHT) - 4) {

red = random(150 + (y * 150) / (2 * WS2812b_HEIGHT / 3), 255);

} else {

if (random(100) < 20) {

red = random(150, 255);

} else {

red = 0;

green = 0;

}}

red += random(-20, 20);

red = constrain(red, 0, 255);

if (y == 7) {

red = (int)(red * 0.10);

green = (int)(green * 0.10);

}

else if (y == 6) {

red = (int)(red * 0.25);

green = (int)(green * 0.25);

}

else if (y == 5) {

red = (int)(red * 0.50);

green = (int)(green * 0.50);

}

else if (y == 4) {

red = (int)(red * 0.75);

green = (int)(green * 0.75);

}

if (y == WS2812b_HEIGHT - 7 && red > 0) {

green = 35;

}

if (y == WS2812b_HEIGHT - 8 && red > 0) {

green = 75;

}

WS2812b.setPixelColor(index, WS2812b.Color(red, green, blue));

}}

WS2812b.show();

delay(150);

}


void loop() {

drawFire();

}