From ff38ca8c19865741469c83ccfb299b125ced229d Mon Sep 17 00:00:00 2001 From: christian Date: Sat, 24 Oct 2026 05:48:09 +0200 Subject: [PATCH] Add LED matrix scrolling text sketch --- sketches/led_matrix_scrolling_text/README.md | 29 +++++++++++++++++ .../led_matrix_scrolling_text.ino | 32 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 sketches/led_matrix_scrolling_text/README.md create mode 100644 sketches/led_matrix_scrolling_text/led_matrix_scrolling_text.ino diff --git a/sketches/led_matrix_scrolling_text/README.md b/sketches/led_matrix_scrolling_text/README.md new file mode 100644 index 0000000..2378d45 --- /dev/null +++ b/sketches/led_matrix_scrolling_text/README.md @@ -0,0 +1,29 @@ +# LED Matrix Scrolling Text + +Løbetekst til den indbyggede 12×8 LED-matrix på Arduino UNO R4 WiFi. + +Teksten ruller fra højre mod venstre og gentages efter en kort pause: + +> Kan AI skrive programmer til Arduino? Tjek https://iot.p20.dev + +Sketchen bruger de officielle biblioteker `ArduinoGraphics` og +`Arduino_LED_Matrix`. `ArduinoGraphics` kan installeres med: + +```powershell +arduino-cli lib install ArduinoGraphics +``` + +## Kompilering + +```powershell +arduino-cli compile --fqbn arduino:renesas_uno:unor4wifi sketches/led_matrix_scrolling_text +``` + +## Upload + +Upload først efter godkendelse: + +```powershell +arduino-cli upload --port COM5 --fqbn arduino:renesas_uno:unor4wifi sketches/led_matrix_scrolling_text +``` + diff --git a/sketches/led_matrix_scrolling_text/led_matrix_scrolling_text.ino b/sketches/led_matrix_scrolling_text/led_matrix_scrolling_text.ino new file mode 100644 index 0000000..f141d9f --- /dev/null +++ b/sketches/led_matrix_scrolling_text/led_matrix_scrolling_text.ino @@ -0,0 +1,32 @@ +#include +#include + +// Scrolling text demo for the Arduino UNO R4 WiFi 12x8 LED matrix. + +constexpr unsigned long SCROLL_SPEED_MS = 75; +constexpr unsigned long REPEAT_PAUSE_MS = 1000; + +const char MESSAGE[] = + "Kan AI skrive programmer til Arduino? Tjek https://iot.p20.dev"; + +ArduinoLEDMatrix matrix; + +void setup() { + matrix.begin(); + matrix.textFont(Font_5x7); + matrix.textScrollSpeed(SCROLL_SPEED_MS); + matrix.clear(); +} + +void loop() { + matrix.beginDraw(); + matrix.stroke(0xFFFFFFFF); + matrix.beginText(12, 1, 0xFFFFFF); + matrix.print(MESSAGE); + matrix.endText(SCROLL_LEFT); + matrix.endDraw(); + + matrix.clear(); + delay(REPEAT_PAUSE_MS); +} +