Here is the second part of the tutorial that shows how to control 32x8 WS2812 LED matrix with Arduino. In this second instalment I will show you how to turn bitmap designs into Arduino code. And also how to use different color schemes when displaying those bitmaps.
The excel tool I present during this video is avialable on my Patreon webpage. I am also posting there 3d printable files for printing diffusion panels for both 32x8 and 8x8 matrix. This work is still in progress But I would post updates each time I improve those 3d designs.
The full tutorial can be found here:
#include <FastLED.h>
#define NUM_LEDS 256
#define DATA_PIN 12
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<WS2812,DATA_PIN,RGB>(leds,NUM_LEDS);
FastLED.setBrightness(150);
}
void loop() {
for (int j=0;j<8;j++)
for (int i=0;i<8;i++){
if (j&1) //odd column
leds[j*8+7-i]=Snake[i][j];
else //even column
leds[j*8+i-1]=Snake[i][j];
delay(50);
FastLED.show();
}
}
#include <FastLED.h>
#define NUM_LEDS 256
#define DATA_PIN 12
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<WS2812,DATA_PIN,RGB>(leds,NUM_LEDS);
FastLED.setBrightness(150);
}
int Arduino [8][32]{
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 111, 128, 0, 0, 0, 0, 0, 0, 0, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 160, 0, 0, 0},
{96, 0, 0, 135, 0, 0, 0, 0, 0, 0, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 178, 0, 0},
{96, 0, 0, 135, 0, 0, 0, 0, 0, 0, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 135, 0, 0, 192, 0},
{96, 111, 128, 135, 0, 160, 178, 0, 192, 210, 96, 0, 111, 0, 135, 0, 160, 0, 178, 192, 210, 0, 96, 111, 128, 0, 0, 0, 0, 0, 192, 0},
{96, 0, 0, 135, 0, 160, 0, 0, 192, 0, 96, 0, 111, 0, 135, 0, 160, 0, 178, 0, 210, 0, 96, 0, 128, 0, 0, 135, 0, 0, 192, 0},
{96, 0, 0, 135, 0, 160, 0, 0, 192, 210, 96, 0, 111, 128, 135, 0, 160, 0, 178, 0, 210, 0, 96, 111, 128, 0, 0, 0, 0, 178, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 160, 0, 0, 0},
};
void loop() {
for (int j=0;j<32;j++)
for (int i=0;i<8;i++){
if (!(j&1)and Arduino[i][j]==0) leds[j*8+i]=CRGB(0,0,0);
if (!(j&1)and Arduino[i][j]!=0) leds[j*8+i]=CHSV(Arduino[i][j],255,255);
if (j&1 and Arduino[i][j]==0 ) leds[j*8+7-i]=CRGB(0,0,0);
if (j&1 and Arduino[i][j]!=0 ) leds[j*8+7-i]=CHSV(Arduino[i][j],255,255);
delay(20);
FastLED.show();
}
}
Displaying text Arduino using single color or randomly generated colors from the HSV color scheme
Arduino#include <FastLED.h>
#define NUM_LEDS 256
#define DATA_PIN 12
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<WS2812,DATA_PIN,RGB>(leds,NUM_LEDS);
FastLED.setBrightness(150);
}
int Arduino [32][8]{
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0},
{1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
{1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0},
{1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0},
{1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0},
{1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0},
};
void loop() {
for (int j=0;j<32;j++)
for (int i=0;i<8;i++){
if (!(j&1) and Arduino[i][j]==1) leds[j*8+i]=CHSV(0,255,255);
if (j&1 and Arduino[i][j]==1) leds[j*8+7-i]=CHSV(0,255,255);
//replace the two lines above with these two to use Random HSV colors
//if (!(j&1) and Arduino[i][j]==1) leds[j*8+i]=CHSV(random(256),255,255);
//if (j&1 and Arduino[i][j]==1) leds[j*8+7-i]=CHSV(random(256),255,255);
FastLED.show();
delay(50);
}
}
Comments