個人資料
  • 博客訪問:
正文

【星壇綜藝會14 期,迎新春】DIY 紅綠藍發光二極管矩陣顯示

(2025-01-26 07:38:08) 下一個

【星壇綜藝會14 期,迎新春】DIY 紅綠藍發光二極管矩陣顯示

RGB LED Matrix Display with Arduino "AIDEXINGKONG 2025 Spring Festival" (愛的星空2025春節)

 

Control Board: Arduino Uno

Display Board: DC5V WS2812B RGB Flexible LED Panel Matrix Programmable Display Screen Lights

 

https://www.youtube.com/watch?v=PMT955n09pA

方法,見我以前發表過的一篇

“DIY: express 'I love you!' for someone for $50”:

https://bbs.wenxuecity.com/rdzn/4940014.html

The Program Code:

#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>

#define DATA_PIN 6

#define arr_len( x ) ( sizeof( x ) / sizeof( *x ) )

// setting matrix
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(32, 8, DATA_PIN,
NEO_MATRIX_TOP +  NEO_MATRIX_LEFT +
NEO_MATRIX_COLUMNS + NEO_MATRIX_PROGRESSIVE + NEO_MATRIX_ZIGZAG,
NEO_GRB + NEO_KHZ800);


char* Text[]= {"AIDEXINGKONG", "2025", "Spring Festival0"}; 
const uint16_t colors[] = {
  matrix.Color(255, 0, 255), matrix.Color(100,255,0), matrix.Color(255,255,0), matrix.Color(0,0,255), matrix.Color(255,0,255), matrix.Color(0,255,255), matrix.Color(255,255,255)};
int brightness = 80;
// end

int numMode =  arr_len(Text) - 1;
int numColor =  arr_len(colors)-1;
int pixelPerChar  =  4;
int maxDisplacement;
int mode =0;

void setup() {
  matrix.begin();
  matrix.setTextWrap(false);
  matrix.setBrightness(brightness);
  matrix.setTextColor(colors[0]);
}
int  y = matrix.height();
int  x = matrix.width();
int pass =  0;
int line_pass =0;

void loop() {
  if (mode > numMode) {mode = 0;}

  matrix.fillScreen(0);
  matrix.setCursor(x, 0);
  scroll(Text[mode], 15);
}
// scrolling
void scroll(char* message, int delays) {
  maxDisplacement = strlen(message) * pixelPerChar + matrix.width();
  if(++line_pass > matrix.width()) line_pass = 0;
 matrix.print(String(message));
 if(--x < -maxDisplacement) {
   x = matrix.width();
   if(++pass  >=  numColor) { pass = 0; };
  matrix.setTextColor(colors[pass]);
  mode++;
  }
  matrix.show();
  delay(delays);
  }
  

 

 

 

[ 打印 ]
閱讀 ()評論 (0)
評論
目前還沒有任何評論
登錄後才可評論.