I am attempting to use an ESP8266 with a 8x32 LED matrix, consisting of 4 chained 8x8 matrices, each controlled by a MAX7219 controller.
I wired it up according to the ESP pin reference (5V - VCC, GND - GND, D7 - DIN, D8 - CS, D5 - CLK) and am now attempting to control it via SPI.h:
#include <SPI.h>
void cmd(uint16_t c, uint8_t data) {
SPI.beginTransaction(SPISettings(1000, MSBFIRST, SPI_MODE0));
digitalWrite(15 /* CS */, LOW);
for (int i = 0; i < 4; i++)
SPI.transfer16((c << 8) | data);
digitalWrite(15 /* CS */, HIGH);
SPI.endTransaction();
}
void setup() {
SPI.begin();
cmd(12, 1);
cmd(1, B01010101);
}
void loop() {
// put your main code here, to run repeatedly:
}
.
However, the LED matrices turn on and off entirely, randomly.
Has anyone had a similar problem, or knows what I did wrong?
Is there a way I can check whether my matrices are still functional?
The MAX7219 does not work reliably with a 3V power supply. You need to give the matrix 5V for the LEDs. Remember to connect the ground of all the power supplies together to avoid other problems.
For a small number of LED modules in the chain you might get away with 3V digital signals but the operation is usually marginal and may not work reliably. You should really be using a signal level converter between ESP8266 and the MAX7219 I/O.
Yes, but not for the other signals. As the chain gets longer there is a voltage drop and this may drop the voltage to below the '1/HIGH' voltage level detected by the IC.