#include <WiFi.h>
#include <Adafruit_GFX.h>
#include <Adafruit_LEDBackpack.h>
//#define WIFI_SSID "parthhvaghanii"
//#define WIFI_PASS "parth123"
// Define the I2C address of the 4-in-1 8x8 Dot Matrix Display module
#define DISPLAY_ADDRESS 0x70
Adafruit_AlphaNum4 matrix = Adafruit_AlphaNum4();
void setup() {
Serial.begin(115200);
matrix.begin(DISPLAY_ADDRESS);
// Connect to WiFi
/*WiFi.begin(WIFI_SSID, WIFI_PASS);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi!");*/
// Set up initial text on the display
matrix.writeDigitAscii(0, 'S');
matrix.writeDigitAscii(1, 'M');
matrix.writeDigitAscii(2, 'A');
matrix.writeDigitAscii(3, 'R');
matrix.writeDisplay();
}
void loop() {
// Check for new messages to display
// You can implement the logic to receive messages from a server or any other source.
String message = "Hello, World!"; // Replace this with your actual message
// Display the message on the matrix display
if (message.length() <= 4) {
for (int i = 0; i < message.length(); i++) {
matrix.writeDigitAscii(i, message[i]);
}
for (int i = message.length(); i < 4; i++) {
matrix.writeDigitAscii(i, ' ');
}
} else {
// If the message is longer than 4 characters, scroll it on the display
for (int i = 0; i < message.length() + 4; i++) {
for (int j = 0; j < 4; j++) {
int charIndex = i + j;
if (charIndex >= message.length()) {
matrix.writeDigitAscii(j, ' ');
} else {
matrix.writeDigitAscii(j, message[charIndex]);
}
}
matrix.writeDisplay();
delay(500); // Adjust the scroll speed if needed
}
}
// Add a delay between messages or checks to avoid flooding the display
delay(3000);
}