Search Code

Projet ESP32-S3 Matrice LED RVB 2 - Texte défilant

Projet ESP32-S3 Matrice LED RVB 2 - Texte défilant


 // Pin oyoza na matrice ya 8×8 RGB 
const int MATRIX_PIN = 14; // esengeli kozala 14 na module oyo // Bola ya matrice (largeur na hauteur)
 const int MATRIX_WIDTH = 8; 
const int MATRIX_HEIGHT = 8; 

// Bongó ya motindo ya matrice mobimba (0–255)
uint8_t matrixBrightness = 40; // bongó ya motindo ya kati oyo esengeli mpo na lopango ya ndako // Na 
setup():
matrix.setBrightness(matrixBrightness);

Soki olobeli panneau na esika ya polele to mpo na ntango mokuse, okoki komatisa motuya oyo, kasi keba ete okota te na likolo mingi soki ozali pene ya display.

Mokanda ya Kotambwisa

Liloba ya solo ebombami lokola string. Na vidéo, mokanda ya ndakisa ezali Robojax. Okoki kobongola yango na etiketi to sikawa ya mokuse nyonso oyo olingi:


 // Mokanda ya kotambwisa na matrice ya 8×8 const char scrollText[] = "Robojax";
 // bongola oyo na sikawa na yo

Kanisa ete oyo ezali kaka matrice ya 8×8, yango wana sikawa milayi mingi ekotambwisa ntango molayi mpe ekoki kokoma makasi mpo na kotanga.

Langi ya Mokanda (Bipai ya RGB)

Langi ya mokanda ya kotambwisa esalemi na bipai ya motane, ya vert, mpe ya bleu (0–255). Na ndakisa, motane ya pete ezali (255, 0, 0), vert ya pete ezali (0, 255, 0), mpe bleu ya pete ezali (0, 0, 255). Na sketch okomona eloko lokola:


 // Langi ya mokanda (R, G, B) uint8_t textRed = 255; // bipai ya motane uint8_t textGreen = 0; // bipai ya vert uint8_t textBlue = 0; // bipai ya bleu

Mpo na kobongola langi:

  • Jaune: textRed = 255; textGreen = 255; textBlue = 0;
  • Cyan: textRed = 0; textGreen = 255; textBlue = 255;
  • Pembe: textRed = 255; textGreen = 255; textBlue = 255;

Vidéo emoniseli mpe kosalela picker ya langi na internet mpo na koluka bipai ya RGB mpe kokoma yango na code.:contentReference[oaicite:1]{index=1}

Mpwaka ya Kotambwisa (Bozongisi kati na Frames)

Mpwaka ya kotambwisa ezwami na motuya ya bozongisi na millisecond kati na etape nyonso ya mise à jour. Motuya moke esalaka ete mokanda etambola mbangu; motuya monene ekitisaka yango. Na sketch, osengeli koluka variable lokola:


// Bozongisi kati na etape ya kotambwisa (na millisecond) int scrollDelayMs = 50;
// moke = mbangu, monene = malembe

Ndakisa:

  • scrollDelayMs = 20; → kotambwisa ya mbangu.
  • scrollDelayMs = 50; → mpwaka ya kati (lokola na vidéo).
  • scrollDelayMs = 100; to koleka → kotambwisa ya malembe, oyo ezali pete mpo na kotanga.

Na kati ya loop(), motuya oyo esalelami na delay(scrollDelayMs); nsima ya kopesa lisusu loposo ya mokanda na esika na yango.

Etaleli ya Kotambwisa (Oponeli)

Na projet ya “kotambwisa ya mokanda ya liboso” tosalelaka mingi kotambwisa na loboko ya gauche, kasi ezali malamu kosala variable ya etaleli mpo okoki komeka etaleli mosusu na nsima (gauche, droite, likolo, na nse).

Mokemoke moko ya momesano ezali:


 // Etaleli ya kotambwisa // 0 = gauche, 1 = droite, 2 = likolo, 3 = na nse
int scrollDirection = 0; // ya liboso: kotambwisa na loboko ya gauche

Loop ya liboso etalaka scrollDirection mpe etambwisaka mokanda na etaleli oyo oponi. Mpo na Projet 2 okoki kotika yango na 0 (gauche), kasi soki okokisa sketch na nsima okoki kobakisa mikakatano lokola:


 if (scrollDirection == 0) {
// tambwisa mokanda na gauche
} else if (scrollDirection == 1) {
// tambwisa mokanda na droite
} else if (scrollDirection == 2) {
// tambwisa mokanda na likolo
} else if (scrollDirection == 3) {
// tambwisa mokanda na nse
}

Mpo na lisolo oyo tokomi kaka configuration. Mise en œuvre ya mobimba ezali eteni ya code oyo ekomami na nse ya lisolo.

Lisele

Projet 2 ebongolaka ESP32-S3 RGB LED Matrix na yo na display ya mokanda ya pete kasi oyo ezali kokamata miso. Na kobongola kaka variables moke na likolo ya code, okoki mbala moko kobongola:

  • Sikawa oyo emonisami (scrollText).
  • Langi ya mokanda (textRed, textGreen, textBlue).
  • Bongó ya motindo ya matrice (matrixBrightness).
  • Mpwaka ya kotambwisa (scrollDelayMs).
  • Etaleli ya kotambwisa (scrollDirection, soki oponi kosalela yango).

Sketch ya mobimba mpo na projet oyo ezali na nse ya lisolo oyo (ezali kokotama na website automatiquement). Mpo na configuration ya etape na etape mpe ndakisa ya bomoi ya mokanda ya kotambwisa na mosala, tala eteni oyo elandi na vidéo. Soki olingi projet oyo mpe olingi kosala yango moko, okoki mpe kosomba module ya ESP32-S3 RGB LED Matrix na ba liens affiliés oyo ezali na nse ya code.

Images

ESP32 S3 Matrix
ESP32 S3 Matrix
ESP32 S3 Matrix  pin out
ESP32 S3 Matrix pin out
ESP32-S3_RGB_8x8_matrix1
ESP32-S3_RGB_8x8_matrix1
ESP32-S3_RGB_8x8_matrix-2
ESP32-S3_RGB_8x8_matrix-2
ESP32-S3-Mtrix - Alway Up
ESP32-S3-Mtrix - Alway Up
800-ESP32-S3 RGB LED Matrix Project 2 - Scrolling Text
Langue: C++
/* 
  Project 2: Text scroll – ESP32-S3 RGB LED Matrix (Waveshare)

  This sketch displays the scrolling text on 8x8 matrix

  ▶️ Video Tutorial:
  https://youtu.be/JKLuYrRcLMI

  📚⬇️ Resources & Code Page:
  https://robojax.com/RJT829

  QMI8658_RGB_2
*/
#include <Arduino.h>
#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>

// -------- LED MATRIX SETUP --------
#define MATRIX_PIN    14
#define MATRIX_WIDTH  8
#define MATRIX_HEIGHT 8

Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(
  MATRIX_WIDTH, MATRIX_HEIGHT, MATRIX_PIN,
  NEO_MATRIX_TOP + NEO_MATRIX_LEFT +
  NEO_MATRIX_ROWS + NEO_MATRIX_PROGRESSIVE,
  NEO_RGB + NEO_KHZ800
);

// =========================
// USER SETTINGS
// =========================

// Text to scroll
const char* MESSAGE = "ROBOJAX ";

// Brightness (0–255)
uint8_t BRIGHTNESS = 10;

// Scroll speed (milliseconds between steps)
// Smaller = faster
uint16_t SCROLL_DELAY = 80;

// Scroll direction
enum ScrollDir {
  SCROLL_LEFT,
  SCROLL_RIGHT,
  SCROLL_UP,
  SCROLL_DOWN
};

// Change this to set direction
ScrollDir DIRECTION = SCROLL_LEFT;

// Text color (set RGB here)
uint8_t COLOR_R = 255; 
uint8_t COLOR_G = 0;
uint8_t COLOR_B = 0;

// =========================
// INTERNAL STATE
// =========================
uint16_t textColor;
int16_t posX, posY;
int16_t textWidth, textHeight;
uint32_t lastStepTime = 0;

// Compute text size in pixels for default 5x7 font
void computeTextSize() {
  int16_t x1, y1;
  uint16_t w, h;
  matrix.getTextBounds((char*)MESSAGE, 0, 0, &x1, &y1, &w, &h);
  textWidth  = (int16_t)w;
  textHeight = (int16_t)h;
}

// Initialize starting position based on direction
void resetScrollPosition() {
  switch (DIRECTION) {
    case SCROLL_LEFT:
      // Start just off the right edge
      posX = matrix.width();
      posY = 0; // top row for 8x8
      break;

    case SCROLL_RIGHT:
      // Start just off the left edge
      posX = -textWidth;
      posY = 0;
      break;

    case SCROLL_UP:
      posX = 0;
      posY = matrix.height(); // start below bottom
      break;

    case SCROLL_DOWN:
      posX = 0;
      posY = -textHeight; // start above top
      break;
  }
}

// One scroll step
void stepScroll() {
  // Move position
  switch (DIRECTION) {
    case SCROLL_LEFT:
      posX--;
      if (posX < -textWidth) {
        posX = matrix.width();
      }
      break;

    case SCROLL_RIGHT:
      posX++;
      if (posX > matrix.width()) {
        posX = -textWidth;
      }
      break;

    case SCROLL_UP:
      posY--;
      if (posY < -textHeight) {
        posY = matrix.height();
      }
      break;

    case SCROLL_DOWN:
      posY++;
      if (posY > matrix.height()) {
        posY = -textHeight;
      }
      break;
  }

  // Draw frame
  matrix.fillScreen(0);
  matrix.setCursor(posX, posY);
  matrix.print(MESSAGE);
  matrix.show();
}

void setup() {
  matrix.begin();
  matrix.setBrightness(BRIGHTNESS);
  matrix.setTextWrap(false);       // No automatic wrapping
  matrix.setTextSize(1);           // Default 5x7 font
  textColor = matrix.Color(COLOR_R, COLOR_G, COLOR_B);
  matrix.setTextColor(textColor);

  computeTextSize();
  resetScrollPosition();

  matrix.fillScreen(0);
  matrix.show();
}

void loop() {
  uint32_t now = millis();
  if (now - lastStepTime >= SCROLL_DELAY) {
    lastStepTime = now;
    stepScroll();
  }
}

Mokili na bisika

Fichiers📁

Fritzing File