Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
Liège 360
Published © CC BY-NC-SA

8x8 WS2812b chaotic colourful Wave Animation

Chaotic colourful Wave Animation for 8x8 matrix.

BeginnerShowcase (no instructions)-60 minutes48
8x8 WS2812b chaotic colourful Wave Animation

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Resistor 4.75k ohm
Resistor 4.75k ohm
×1
Adafruit NeoPixel NeoMatrix 8x8 - 64 RGB LED Pixel Matrix
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

colourful_wave.ino

C/C++
#include "Adafruit_NeoPixel.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 chaoticWaveAnimation() {
delay(30); 
WS2812b.setBrightness(100);
static uint8_t hueOffset = 0; 
static uint8_t wavePos[WS2812b_WIDTH]; 
for (int i = 0; i < WS2812b_WIDTH; i++) {
wavePos[i] += random(1, 4); 
if (wavePos[i] >= WS2812b_HEIGHT * 2) {
wavePos[i] = 0; 
}}
WS2812b.clear();
for (int x = 0; x < WS2812b_WIDTH; x++) {
for (int y = 0; y < WS2812b_HEIGHT; y++) {
int distance = abs(y - (wavePos[x] % WS2812b_HEIGHT));
if (distance < 3) { 
float wave = sin((hueOffset + x + y) * 0.1);
uint8_t brightness = 128 + (127 * wave); 
uint8_t hue = hueOffset + (x * 10) + (y * 5); 
uint32_t color = WS2812b.ColorHSV(hue * 256, 255, brightness); 
int pixelIndex = y * WS2812b_WIDTH + x;
WS2812b.setPixelColor(pixelIndex, color);
}}}
WS2812b.show();
hueOffset += 2;
}

void loop() {
chaoticWaveAnimation();
}

Credits

Liège 360
21 projects • 0 followers
Contact

Comments

Please log in or sign up to comment.