Introduction
In this project, we’ll walk through how to use an ESP8266 microcontroller to control a scrolling text display using LED Matrix Modules and the MD_MAX72XX library. This setup allows you to scroll messages that are dynamically sent from a web browser.
Key Features:
- Control the scrolling text using a web browser.
- ESP8266 handles the WiFi communication.
- 4 LED matrix modules for displaying messages.
Image Suggestion:
Add an image of the setup, like the one you uploaded showing the scrolling “Hello” message.
Materials Required
To build this project, you’ll need the following components:
- ESP8266 (such as NodeMCU or Wemos D1 Mini)
- 4-in-1 LED Matrix (MAX7219)
- Jumper wires
- Breadboard
- Power supply (3.3V for ESP8266, 5V for LED matrix)
Circuit Diagram
Connections for ESP8266 and LED Matrix:
ESP8266 Pin | LED Matrix Pin |
---|---|
3.3V | VCC |
GND | GND |
D7 | DIN |
D8 | CS |
D5 | CLK |
Make sure you connect the power and data pins properly, or the display may not work as expected.
Code Explanation
Below is the full Arduino sketch to run the scrolling text display and control it via a web browser:
///////////////////////
#include <ESP8266WiFi.h>
#include <MD_MAX72XX.h>
#include <SPI.h>#define MAX_DEVICES 4
#define CLK_PIN D5
#define DATA_PIN D7
#define CS_PIN D8
#define SSID “your_wifi_name”
#define PASSWORD “your_wifi_password”MD_MAX72XX mx = MD_MAX72XX(MD_MAX72XX::PAROLA_HW, CS_PIN, MAX_DEVICES);
WiFiServer server(80);char message[] = “Hello World! “;
bool newMessage = false;void setup() {
Serial.begin(115200);
mx.begin();
connectToWiFi();
server.begin();
}void loop() {
handleWiFi();
scrollText();
}void connectToWiFi() {
WiFi.begin(SSID, PASSWORD);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(“.”);
}
Serial.println(“Connected to WiFi.”);
}void handleWiFi() {
WiFiClient client = server.available();
if (!client) return;
while (client.connected()) {
if (client.available()) {
String request = client.readStringUntil(‘\r’);
client.flush();
if (request.indexOf(“GET /message?”) >= 0) {
String newMsg = request.substring(request.indexOf(‘=’) + 1);
newMsg.trim();
newMsg.replace(“%20″, ” “);
newMsg.toCharArray(message, newMsg.length() + 1);
newMessage = true;
}
client.println(“HTTP/1.1 200 OK”);
client.println(“Content-Type: text/html”);
client.println(“”);
client.println(“<form action=\”/message\”>Message: <input type=’text’ name=’msg’><input type=’submit’></form>”);
break;
}
}
}void scrollText() {
if (newMessage) {
mx.clear();
for (int i = 0; i < strlen(message); i++) {
mx.setChar(i, message[i]);
}
newMessage = false;
}
mx.update();
delay(75);
}
///////////////////////
Steps in the Code
- WiFi Setup: The ESP8266 connects to your local WiFi using the credentials.
- Web Server: The ESP8266 creates a web server that allows the user to input a message through a browser.
- Message Handling: The message is updated and scrolled on the LED matrix display.
- Scrolling Mechanism: The
scrollText()
function handles the continuous scrolling of text.
Video Demonstration
Here is a video demonstration of the project in action. The text “Hello” scrolls across four LED matrices, controlled by the ESP8266:
Challenges and Solutions
- Library Errors: If you encounter issues like
MD_MAX72XX.h: No such file or directory
, make sure the library is correctly installed. You can install it through the Arduino Library Manager or PlatformIO as explained earlier. - WiFi Connection: If the ESP8266 isn’t connecting to your WiFi, double-check your SSID and password. Make sure the ESP8266 is within range of the router.
- Scrolling Issues: If the text isn’t scrolling properly, ensure the wiring between the ESP8266 and the LED matrix is correct, especially the CLK and DIN pins.