filmov
tv
WS2812b RGB LED Matrix With Scrolling Text using an Arduino

Показать описание
Here's an WS2812B LED Matrix using a bottom left zig zag pattern. it is using the adafruit neomatrix as well as fast LED libraries.
the below code is for the same scrolling effect though uses a more efficient library. there's also bouncing balls in it. there are comments that state what where certain things do certain things
TO USE THIS CODE!!
Be sure to get the following Libraries
Adafruit_gfx
FastLED
FastLED_NeoMatrix
Replace the following characters
(((( Left facing culry bracket
)))) right facing curly bracket
zz)zz) angled bracket pointing right
(zz(zz angled bracket pointing left
XXXXXXXXXXXXCODEXXXXXXXXXXXXXXXXXXXX
//this is different than the video and uses a different library which is faster
//Required Libraries
#include (zz(zzAdafruit_GFX.hzz)zz)
#include (zz(zzFastLED.hzz)zz)
//Pin assignment change as needed
#define PIN 2
//set these for matrix size (width and height)
#define mw 32
#define mh 8
#define NUMMATRIX (mw*mh)
CRGB matrixleds[NUMMATRIX];
//this is matrix constructor change to suit your configuration
//if your matrix starts at the bottom left and zig zags then use this one.
//change the NEO_MATRIX_//X to suit your configuration
FastLED_NeoMatrix *matrix = new FastLED_NeoMatrix(matrixleds, 24, 24,
NEO_MATRIX_BOTTOM + NEO_MATRIX_LEFT +
NEO_MATRIX_ROWS + NEO_MATRIX_ZIGZAG);
//you don't have to touch much here unless you want to
const uint16_t colors[] = ((((
matrix-zz)zz)Color(255, 0, 0), matrix-zz)zz)Color(0, 255, 0), matrix-zz)zz)Color(0, 0, 255) ))));
int j = 3;
int xa,xb,ya,yb,vxa,vxb,vya,vyb,r;
int fc,b,radi;
void setup() ((((
FastLED.addLeds(zz(zzWS2812B,PINzz)zz)(matrixleds, NUMMATRIX);
//FastLED.addLeds(zz(zzWS2812B,2zz)zz)(matrixleds, NUMMATRIX/3).setCorrection(TypicalLEDStrip);
matrix-zz)zz)begin();
matrix-zz)zz)setTextWrap(false);
matrix-zz)zz)setBrightness(150);
matrix-zz)zz)setTextColor(colors[0]);
matrix-zz)zz)setTextSize(2,2);
for (j = 0; j(zz(zz3-1;j++)((((
xa = random(23);
xb = random(23);
ya = random(23);
yb = random(23);
vxa = random(3)+1;
vxb = random(3)+1;
vya = random(3)+1;
vyb = random(3)+1;
r = random(150)+150;
fc = random(150);
b = random(200)+50;
radi= random(3)+2;
))))
))))
int x = mw;
int pass = 0;
int fillcolor = 0;
int loopsaround = 0;
void loop() ((((
//this can be changed to change the color of the background
matrix-zz)zz)fillScreen(matrix-zz)zz)Color(fillcolor,fillcolor,fillcolor));
//for(j = 0; j(zz(zz5-1;j++)((((
j=2;
xa=xa+vxa;
xb=xb+vxb;
ya=ya+vya;
yb=yb+vyb;
if (xa(zz(zz0+j || xazz)zz)mw-j)((((
vxa = -vxa;
xa = xa + vxa;
))))
if (ya(zz(zz0+j || yazz)zz)mh-j)((((
vya = -vya;
ya = ya + vya;
))))
if (xb(zz(zz0+j || xbzz)zz)mw-j)((((
vxb = -vxb;
xb = xb + vxb;
))))
if (yb(zz(zz0+j || ybzz)zz)mh-j)((((
vyb = -vyb;
yb = yb + vyb;
))))
//this is just to change the balls bouncing around to change direction a bit
if(++loopsaround zz)zz) 500)((((
vxa = random(3)+1;
vxb = random(3)+1;
vya = random(3)+1;
vyb = random(3)+1;
loopsaround=0;
r = random(150)+150;
fc = random(150);
b = random(200)+50;
radi=random(3)+2;
))))
//these are the balls that bounce
matrix-zz)zz)fillCircle(xa,ya,3,matrix-zz)zz)Color(r,254,b-60));
matrix-zz)zz)fillCircle(xb,yb,4,matrix-zz)zz)Color(254,0,b));
//this sets your text size for scrolling
if(--x (zz(zz -160) ((((
x = matrix-zz)zz)width();
if(++pass zz)zz)= 3) pass = 0;
matrix-zz)zz)setTextColor(matrix-zz)zz)Color(random(254),random(254),random(254)));
))))
matrix-zz)zz)setCursor(x,5);//matrix-zz)zz)setCursor(x, 0);
matrix-zz)zz)print(F("Here's the message displayed"));
matrix-zz)zz)show();
delay(20);
))))
the below code is for the same scrolling effect though uses a more efficient library. there's also bouncing balls in it. there are comments that state what where certain things do certain things
TO USE THIS CODE!!
Be sure to get the following Libraries
Adafruit_gfx
FastLED
FastLED_NeoMatrix
Replace the following characters
(((( Left facing culry bracket
)))) right facing curly bracket
zz)zz) angled bracket pointing right
(zz(zz angled bracket pointing left
XXXXXXXXXXXXCODEXXXXXXXXXXXXXXXXXXXX
//this is different than the video and uses a different library which is faster
//Required Libraries
#include (zz(zzAdafruit_GFX.hzz)zz)
#include (zz(zzFastLED.hzz)zz)
//Pin assignment change as needed
#define PIN 2
//set these for matrix size (width and height)
#define mw 32
#define mh 8
#define NUMMATRIX (mw*mh)
CRGB matrixleds[NUMMATRIX];
//this is matrix constructor change to suit your configuration
//if your matrix starts at the bottom left and zig zags then use this one.
//change the NEO_MATRIX_//X to suit your configuration
FastLED_NeoMatrix *matrix = new FastLED_NeoMatrix(matrixleds, 24, 24,
NEO_MATRIX_BOTTOM + NEO_MATRIX_LEFT +
NEO_MATRIX_ROWS + NEO_MATRIX_ZIGZAG);
//you don't have to touch much here unless you want to
const uint16_t colors[] = ((((
matrix-zz)zz)Color(255, 0, 0), matrix-zz)zz)Color(0, 255, 0), matrix-zz)zz)Color(0, 0, 255) ))));
int j = 3;
int xa,xb,ya,yb,vxa,vxb,vya,vyb,r;
int fc,b,radi;
void setup() ((((
FastLED.addLeds(zz(zzWS2812B,PINzz)zz)(matrixleds, NUMMATRIX);
//FastLED.addLeds(zz(zzWS2812B,2zz)zz)(matrixleds, NUMMATRIX/3).setCorrection(TypicalLEDStrip);
matrix-zz)zz)begin();
matrix-zz)zz)setTextWrap(false);
matrix-zz)zz)setBrightness(150);
matrix-zz)zz)setTextColor(colors[0]);
matrix-zz)zz)setTextSize(2,2);
for (j = 0; j(zz(zz3-1;j++)((((
xa = random(23);
xb = random(23);
ya = random(23);
yb = random(23);
vxa = random(3)+1;
vxb = random(3)+1;
vya = random(3)+1;
vyb = random(3)+1;
r = random(150)+150;
fc = random(150);
b = random(200)+50;
radi= random(3)+2;
))))
))))
int x = mw;
int pass = 0;
int fillcolor = 0;
int loopsaround = 0;
void loop() ((((
//this can be changed to change the color of the background
matrix-zz)zz)fillScreen(matrix-zz)zz)Color(fillcolor,fillcolor,fillcolor));
//for(j = 0; j(zz(zz5-1;j++)((((
j=2;
xa=xa+vxa;
xb=xb+vxb;
ya=ya+vya;
yb=yb+vyb;
if (xa(zz(zz0+j || xazz)zz)mw-j)((((
vxa = -vxa;
xa = xa + vxa;
))))
if (ya(zz(zz0+j || yazz)zz)mh-j)((((
vya = -vya;
ya = ya + vya;
))))
if (xb(zz(zz0+j || xbzz)zz)mw-j)((((
vxb = -vxb;
xb = xb + vxb;
))))
if (yb(zz(zz0+j || ybzz)zz)mh-j)((((
vyb = -vyb;
yb = yb + vyb;
))))
//this is just to change the balls bouncing around to change direction a bit
if(++loopsaround zz)zz) 500)((((
vxa = random(3)+1;
vxb = random(3)+1;
vya = random(3)+1;
vyb = random(3)+1;
loopsaround=0;
r = random(150)+150;
fc = random(150);
b = random(200)+50;
radi=random(3)+2;
))))
//these are the balls that bounce
matrix-zz)zz)fillCircle(xa,ya,3,matrix-zz)zz)Color(r,254,b-60));
matrix-zz)zz)fillCircle(xb,yb,4,matrix-zz)zz)Color(254,0,b));
//this sets your text size for scrolling
if(--x (zz(zz -160) ((((
x = matrix-zz)zz)width();
if(++pass zz)zz)= 3) pass = 0;
matrix-zz)zz)setTextColor(matrix-zz)zz)Color(random(254),random(254),random(254)));
))))
matrix-zz)zz)setCursor(x,5);//matrix-zz)zz)setCursor(x, 0);
matrix-zz)zz)print(F("Here's the message displayed"));
matrix-zz)zz)show();
delay(20);
))))
Комментарии