呢個教學係以下嘅一部分: ESP32-S3 RGB LED 点阵
这是一个很棒的项目,可以使用 ESP32-S3 RGB 矩阵模块进行创作,兼具趣味性和实用性。本文下方有其他相关视频的链接。
ESP32-S3 RGB LED矩陣互聯網時鐘項目 - 3種夜間顏色連日期
ESP32-S3 RGB NeoMatrix 網絡時鐘(自動日夜亮度調節)
呢個項目係一個 ESP32-S3 RGB Matrix 網絡時鐘,會自動喺日頭同夜晚調節亮度。ESP32-S3 會連接 Wi-Fi,從 NTP 伺服器同步當前時間,並以 HH:MM 格式將時間滾動顯示喺 8×8 RGB NeoMatrix 上面。個時鐘仲支援固定或循環 RGB 顏色嚟顯示文字。

呢個時鐘做啲乜
開機之後,ESP32-S3 會連接你嘅 Wi-Fi 網絡,並從互聯網攞返當前嘅本地時間。時間會順暢噉滾動顯示喺 LED 矩陣上面。喺夜晚時段,顯示器會自動調暗到較低亮度,而日頭就會切返去較光嘅水平。
用到嘅程式庫
呢個程式用到以下程式庫:

#include <WiFi.h>
#include "time.h"
#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
從 Arduino Library Manager 安裝 Adafruit NeoMatrix。所有需要嘅依賴程式庫,例如 Adafruit GFX Library 同 Adafruit NeoPixel,都會自動安裝。

重要嘅用戶設定
Wi-Fi SSID 同密碼(大小寫敏感)
將以下數值替換成你自己嘅 Wi-Fi 憑證:

const char* WIFI_SSID = "WiFi";
const char* WIFI_PASSWORD = "passW0rd";
重要: Wi-Fi SSID 係大小寫敏感嘅。一個叫 "Book" 嘅 SSID 唔等於 "book"。如果大細階唔完全脗合,ESP32 就會連接失敗。
NTP 伺服器、時區同夏令時間
個時鐘用以下 NTP 伺服器嚟同步時間:
const char* ntpServer = "pool.ntp.org";
本地時間用以下偏移量嚟計算:
const long gmtOffset_sec = -5 * 3600;
const int daylightOffset_sec = 3600;
gmtOffset_sec定義你嘅 UTC 偏移量(以秒計)daylightOffset_sec喺夏令時間生效時加一個鐘(唔需要就設做0)
呢啲數值會用以下方式套用:
configTime(gmtOffset_sec, daylightOffset_sec, ntpServer);
自動日夜亮度調節
顯示器亮度會根據當前小時自動改變:
const int DAY_BRIGHTNESS = 40;
const int NIGHT_BRIGHTNESS = 5;
const int NIGHT_START_HOUR = 22; // 夜晚 10 點
const int NIGHT_END_HOUR = 6; // 朝早 6 點
喺夜晚 10 點到朝早 6 點之間,矩陣亮度會降低,令到喺黑暗環境入面睇得舒服啲。喺呢段時間以外,就會恢復全日亮度。你可以調整呢啲數值嚟配合你房間嘅光線。
RGB 顏色設定
時鐘文字顏色用 RGB(紅、綠、藍)數值嚟定義,每個通道範圍由 0 到 255。可以將多種顏色儲存喺陣列入面並自動循環:
uint8_t userColors[][3] = {
{17, 43, 171}, // 淺藍色
{255, 0, 0}, // 紅色
{0, 255, 0}, // 綠色
{255, 165, 0}, // 橙色
{255, 0, 255} // 洋紅色
};
如果 useFixedColor 設做 true,個時鐘就永遠用一種顏色。如果設做 false,顏色就會喺每次完整滾動時間之後自動改變。
想快速搵到任何顏色嘅準確 RGB 數值,可以用 RGB 顏色揀色器工具: 顏色揀色器 。
時間顯示同滾動
當前時間會格式化做 HH:MM 並儲存喺一個細嘅字元緩衝區入面。因為顯示器得 8 像素闊,文字會由右到左順暢噉滾動。一旦時間完全離開顯示器,就會揀下一個顏色(如果啟用咗)用喺下一輪。
示範
上傳程式之後:
- ESP32-S3 會連接 Wi-Fi
- 時間會從互聯網同步
- 當前時間會滾動顯示喺 RGB 矩陣上面
- 亮度會自動喺日頭同夜晚之間切換
- 文字顏色會根據你嘅設定保持固定或者循環改變
下載同連結
完整嘅原始碼喺呢篇文章下面提供。零件、工具同數據表嘅連結都喺呢篇文章下面提供。
呢個教學係以下嘅一部分: ESP32-S3 RGB LED 点阵
- ESP32-S3 RGB LED矩陣項目1-基本點
- ESP32-S3 RGB LED矩陣項目2 - 滾動文字
- ESP32-S3 RGB LED矩陣項目3 - 手機文字
- ESP32-S3 RGB LED矩陣項目 4 - 傾斜點
- ESP32-S3 RGB LED矩陣項目5 - 箭嘴永遠向上
- ESP32-S3 RGB LED矩陣項目6 - Cible遊戲
- ESP32-S3 RGB LED矩陣 Wi-Fi + NTP時鐘項目 -1 基本時鐘
- ESP32-S3 RGB LED矩陣網絡時鐘項目 - 2個時鐘多色時間及日期顯示
- ESP32-S3 RGB LED矩陣網絡時鐘項目 - 5 彩虹色
- ESP32-S3 RGB LED矩陣網絡時鐘項目 - 4種隨機顏色
- ESP32-S3 RGB LED Matrix test for RGB, GRB setting
/*
* =====================================================================================
* ESP32-S3 INTERNET RGB CLOCK (8x8 Matrix) - Project 3- Night color with Date
* =====================================================================================
watch video https://youtube.com/shorts/4iWjLiD7fS8
📚⬇️ Download and resource page https://robojax.com/RJT840
* Author: Gemini (AI Thought Partner) & Ahmad Shamshiri (Robojax.com)
* Date: 07 Jan 2026
* * FEATURES:
* 1. WiFi/NTP Time: Syncs automatically with internet time servers.
* 2. Cycle-Based Color: Color changes ONLY after the time finishes a full scroll.
* 3. Auto-Brightness: Dims the LEDs during night hours (User-configurable).
* =====================================================================================
*/
#include <WiFi.h>
#include "time.h"
#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
#define MATRIX_PIN 14
// --- BRIGHTNESS CONFIGURATION ---
const int DAY_BRIGHTNESS = 40;
const int NIGHT_BRIGHTNESS = 5;
const int NIGHT_START_HOUR = 22; // 10 PM
const int NIGHT_END_HOUR = 6; // 6 AM
// --- COLOR CONFIGURATION ---
bool useFixedColor = false;
int fixedColorIndex = 0;
uint8_t userColors[][3] = {
{17, 43, 171}, // Light Blue
{255, 0, 0}, // Red
{0, 255, 0}, // Green
{255, 165, 0}, // Orange
{255, 0, 255} // Magenta
};
// 👇 REPLACE these with your real home WiFi name & password
const char* WIFI_SSID = "WiFi";
const char* WIFI_PASSWORD = "passW0rd";
int currentColorIndex = 0;
int totalColors = sizeof(userColors) / sizeof(userColors[0]);
// --- INTERVALS ---
unsigned long lastTimeUpdateMs = 0;
const uint16_t timeUpdateIntervalMs = 1000;
unsigned long lastScrollMs = 0;
const uint16_t scrollIntervalMs = 100;
// --- GLOBAL VARIABLES ---
Adafruit_NeoMatrix matrix(8, 8, MATRIX_PIN,
NEO_MATRIX_TOP + NEO_MATRIX_LEFT +
NEO_MATRIX_ROWS + NEO_MATRIX_PROGRESSIVE,
NEO_RGB + NEO_KHZ800);
char timeText[6] = "00:00";
int16_t scrollX = 8;
const char* ntpServer = "pool.ntp.org";
const long gmtOffset_sec = -5 * 3600;
const int daylightOffset_sec = 3600;
void updateTimeText() {
struct tm timeinfo;
if (!getLocalTime(&timeinfo)) return;
// Format HH:MM
snprintf(timeText, sizeof(timeText), "%02d:%02d", timeinfo.tm_hour, timeinfo.tm_min);
// Apply Auto-Brightness
if (timeinfo.tm_hour >= NIGHT_START_HOUR || timeinfo.tm_hour < NIGHT_END_HOUR) {
matrix.setBrightness(NIGHT_BRIGHTNESS);
} else {
matrix.setBrightness(DAY_BRIGHTNESS);
}
}
void scrollTime() {
matrix.fillScreen(0);
// Pick the color (Fixed or Cycle)
int idx = useFixedColor ? fixedColorIndex : currentColorIndex;
matrix.setTextColor(matrix.Color(userColors[idx][0], userColors[idx][1], userColors[idx][2]));
matrix.setCursor(scrollX, 0);
matrix.print(timeText);
matrix.show();
scrollX--;
// Width for "HH:MM" is roughly 30 pixels
int16_t textWidth = 30;
// TRIGGER: When time is fully off-screen
if (scrollX < -textWidth) {
scrollX = matrix.width(); // Reset position to right side
// Cycle to the next color in the array for the next pass
if (!useFixedColor) {
currentColorIndex = (currentColorIndex + 1) % totalColors;
Serial.print("Next cycle color index: ");
Serial.println(currentColorIndex);
}
}
}
void setup() {
Serial.begin(115200);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
configTime(gmtOffset_sec, daylightOffset_sec, ntpServer);
matrix.begin();
matrix.setTextWrap(false);
matrix.setBrightness(DAY_BRIGHTNESS);
updateTimeText();
}
void loop() {
unsigned long now = millis();
// Update time digits and brightness once per second
if (now - lastTimeUpdateMs >= timeUpdateIntervalMs) {
lastTimeUpdateMs = now;
updateTimeText();
}
// Handle the scrolling animation
if (now - lastScrollMs >= scrollIntervalMs) {
lastScrollMs = now;
scrollTime();
}
}
你可能需要嘅嘢
-
亞馬遜
-
易贝
-
阿里巴巴速卖通Purchase ESP32-S3 RGB matrix from AliExpresss.click.aliexpress.com
-
阿里巴巴速卖通Purchase ESP32-S3 RGB matrix from AliExpress (2)s.click.aliexpress.com
資源與參考資料
-
視頻
-
內部🎨 Color picker Toolrobojax.com
文件📁
Fritzing 文件
-
esp32-S3-supermini-tht fritzing part
esp32-S3-supermini-tht.fzpz0.02 MB