8x8 WS2812b Animated Fire Effect

by wilsnico in Circuits > Arduino

3 Views, 0 Favorites, 0 Comments

8x8 WS2812b Animated Fire Effect

1000028511.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.

video effect :

https://drive.google.com/file/d/1-H51IYxO6GoujdcxpEJ7sNvCGHf-780T/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(20);

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 = 30, blue = 0;

if (y == 0) {

red = random(100, 255);

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

red = random(100 + (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);

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

}}

WS2812b.show();

delay(100);

}


void loop() {

drawFire();

}