I'm using a P10 display with the model P10-1921-8S-32x16-B, but I can't seem to control the LEDs to display anything properly using the PxMatrix library along with Adafruit_GFX and Ticker. The output is always the same: rows 1–4 are off, 5–8 are on, 9–12 are off, and 13–16 are on.
Here is the wiring configuration I'm using (ESP8266 to P10 panel):
P_A 5 // D1
P_B 4 // D2
R_1 0// D3
R_2 2// D4
P_CLK 14 // D5
P_LAT 12 // D6
P_OE 13 // D7
P_C 15 // D8
I'm currently testing only the red color.
The problem is: I can't control the LEDs correctly. Sometimes, only certain rows light up, and other times the display turns white—even though I'm only trying to show red. What could be causing this issue?
here is my code : please ignore the html first
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <Adafruit_GFX.h>
#include <PxMatrix.h>
#include <Ticker.h>
const char* ssid = "bla";
const char* password = "blablalba";
ESP8266WebServer server(80);
#define P_CLK 14 // D5
#define P_LAT 12 // D6
#define P_OE 13 // D7
#define P_A 5 // D1
#define P_B 4 // D2
#define P_C 15 // D8
#define DISPLAY_WIDTH 32
#define DISPLAY_HEIGHT 16
PxMATRIX display(DISPLAY_WIDTH, DISPLAY_HEIGHT, P_CLK, P_LAT, P_OE, P_A, P_B, P_C);
Ticker display_ticker;
String incomingText = "selamat";
int scrollPosition = DISPLAY_WIDTH;
int brightness = 0;
int scrollSpeed = 100;
void display_updater() {
display.display(70);
}
void handleRoot() {
String html = R"rawliteral(
<!DOCTYPE html>
<html>
<head><title>P10 Display Control</title></head>
<body style="font-family:sans-serif; text-align:center;">
<h2>ESP8266 P10 LED Display</h2>
<form action="/send" method="POST">
<input type="text" name="msg" placeholder="Enter text to display" style="width:300px; padding:10px;" />
<br><br>
<input type="submit" value="Send to LED Display" style="padding:10px; font-size:16px;" />
</form>
<br><br>
<form action="/brightness" method="POST">
<label for="brightness">Brightness:</label><br>
<input type="range" name="level" min="0" max="255" value=")rawliteral" + String(brightness) + R"rawliteral(" oninput="brightnessValue.innerText = this.value">
<span id="brightnessValue">)rawliteral" + String(brightness) + R"rawliteral(</span><br><br>
<input type="submit" value="Set Brightness" style="padding:10px; font-size:16px;" />
</form>
<br><br>
<a href="/info" style="font-size:16px;">Lihat Info Komunikasi</a>
</body>
</html>
)rawliteral";
server.send(200, "text/html", html);
}
void handleSend() {
if (server.hasArg("msg")) {
incomingText = server.arg("msg");
scrollPosition = DISPLAY_WIDTH;
}
server.sendHeader("Location", "/");
server.send(303);
}
void handleBrightness() {
if (server.hasArg("level")) {
brightness = server.arg("level").toInt();
display.setBrightness(brightness);
}
server.sendHeader("Location", "/");
server.send(303);
}
void handleInfo() {
String infoHtml = R"rawliteral(
<!DOCTYPE html>
<html>
<head>
<title>Info Komunikasi</title>
<style>
@keyframes scrollText {
0% { left: 100%; }
100% { left: -100%; }
}
.scroll-container {
border: 2px solid #000;
width: 320px;
height: 32px;
margin: auto;
background: black;
overflow: hidden;
position: relative;
}
.scroll-text {
color: red;
white-space: nowrap;
font-size: 24px;
position: absolute;
left: 100%;
animation: scrollText 10s linear infinite;
}
</style>
</head>
<body style='font-family:sans-serif; text-align:center;'>
<h2>Informasi Komunikasi</h2>
<p><strong>WiFi SSID:</strong> )rawliteral" + String(ssid) + R"rawliteral(</p>
<p><strong>IP Address:</strong> )rawliteral" + WiFi.localIP().toString() + R"rawliteral(</p>
<p><strong>Brightness:</strong> )rawliteral" + String(brightness) + R"rawliteral(</p>
<p><strong>Teks Berjalan:</strong> )rawliteral" + incomingText + R"rawliteral(</p>
<h3>Simulasi LED Display</h3>
<div class="scroll-container">
<div class="scroll-text" id="previewText">)rawliteral" + incomingText + R"rawliteral(</div>
</div>
<br><br><a href='/'>Kembali ke Halaman Utama</a>
</body>
</html>
)rawliteral";
server.send(200, "text/html", infoHtml);
}
void setup() {
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) delay(500);
display.begin(8);
display.setFastUpdate(true);
display.setTextWrap(false);
display.setBrightness(brightness);
display.clearDisplay();
display_ticker.attach_ms(1, display_updater);
server.on("/", handleRoot);
server.on("/send", HTTP_POST, handleSend);
server.on("/brightness", HTTP_POST, handleBrightness);
server.on("/info", HTTP_GET, handleInfo);
server.begin();
//SPEED SCROLL
server.on("/speed", HTTP_POST, []() {
if (server.hasArg("val")) {
scrollSpeed = server.arg("val").toInt();
}
server.sendHeader("Location", "/");
server.send(303);
});
}
void loop() {
server.handleClient();
display.fillScreen(0); // clear
int cursorX = scrollPosition;
int charWidth = 6; // default lebar karakter (5 px + 1 px spasi)
display.setTextColor(display.color565(255, 0, 0)); // warna merah
for (int i = 0; i < incomingText.length(); i++) {
if (cursorX > -charWidth && cursorX < DISPLAY_WIDTH) {
display.drawChar(cursorX, 0, incomingText[i], display.color565(255, 0, 0), 0, 1);
}
cursorX += charWidth;
}
scrollPosition--;
if (scrollPosition < -((int)incomingText.length() * charWidth)) {
scrollPosition = DISPLAY_WIDTH;
}
delay(scrollSpeed);
}



