#include <Arduino.h>
#include <U8g2lib.h>
#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif
// Initialize the display
U8G2_MAX7219_32X8_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE);
void setup(void) {
// Begin the display
u8g2.begin();
// Set the display contrast
u8g2.setContrast(160);
}
void loop(void) {
// Set the font for the display
u8g2.setFont(u8g2_font_victoriabold8_8r);
// Calculate the width of the string
int strWidth = u8g2.getStrWidth("HI I AM KAI29 FROM THAI HAVE A NICE DAY");
// Loop to scroll the text from right to left
for (int i = 32; i >= -strWidth; i--) {
u8g2.clearBuffer(); // clear the internal memory
u8g2.drawStr(i, 8, "I AM KAI29 FROM THAI HAVE A NICE DAY"); // write something to the internal memory
u8g2.sendBuffer(); // transfer internal memory to the display
delay(100); // delay between each scroll step
}
}