Problem with led matrix on Esp8266

Hello there!

I'm trying to build my first project using Esp8266 Nodemcu and LED 8x8 Max7219. I found a few online tutorials, but nothing works for me. The LED screen lights up red without any changes.
I would appreciate it if somebody could hint at what I'm doing wrong :pray:

Code:

#include <LedControl.h>

int DIN = 12; // D6
int CS = 15; // D8
int CLK = 14; // D5
unsigned long delaytime=1000;

LedControl lc=LedControl(DIN,CLK,CS,1);

byte smile[8]= {0x3C,0x42,0xA5,0x81,0xA5,0x99,0x42,0x3C};
byte neutral[8]={0x3C,0x42,0xA5,0x81,0xBD,0x81,0x42,0x3C};
byte sad[8]= {0x3C,0x42,0xA5,0x81,0x99,0xA5,0x42,0x3C};

void setup() {
lc.shutdown(0,false);
lc.setIntensity(0,8);
lc.clearDisplay(0);
}

void loop(){
printByte(smile);
delay(delaytime);
printByte(neutral);
delay(delaytime);
printByte(sad);
delay(delaytime);
}

void printByte(byte character [])
{
int i = 0;
for(i=0;i<8;i++)
{
lc.setRow(0,i,character[i]);
}
}

The module VCC should probably run better from the VIN than the 3V3.

It doesn't help. I also tried to use D0, D1 and D2 (instead of D5, D6, D8) and it also didn't work.

Please insert the code to the forum using the code tags.
Download the files from external link is not in traditions of the community

1 Like

@naivekook

I remembered that I have a few '7219 boards, so I pulled one out and soldered the pins to it and checked it out with the Arduino UNO.
That went OK (except how I reckon where Row 0 and Col 0 are vs. the sketch & the boards implementation/s).

I made some pins changes and uploaded to a NodeMCU and. . . it tanked.
I noticed the 'D4' LED blinking periodically → Not Good.
Enabling the SerialMonitor I saw that a Crash Log gets knocked out (wdt reset) and, further, determined that it never gets into setup().

LedControl.h may not be "ESP Ready".

#include <LedControl.h>
//#include <Arduino.h>

const byte din = 14;
const byte cs = 13;
const byte clk = 12;

int col;
int row;
 
LedControl lc=LedControl(12,10,11,1);  // din, clk, load_cs 

/* we always wait a bit between updates of the display */
unsigned long delaytime = 1000;
unsigned long delaytime2 = 50;

byte a[5]={B01111110,B00010001,B00010001,B00010001,B01111110};
byte r[5]={B01111100,B00001000,B00000100,B00000100,B00001000};
byte d[5]={B00111000,B01000100,B01000100,B01001000,B01111111};
byte u[5]={B00111100,B01000000,B01000000,B00100000,B01111100};
byte i[5]={B00000000,B01000100,B01111101,B01000000,B00000000};
byte n[5]={B01111100,B00001000,B00000100,B00000100,B01111000};
byte o[5]={B00111000,B01000100,B01000100,B01000100,B00111000};

void setup() 
{
  //Serial.begin(115200);
  //delay(2000);
  //Serial.println("ok ok");
  lc.shutdown(0,false);  // wake-up
  /* Set the brightness to a medium values */
  lc.setIntensity(0,2);
  /* and clear the display */
  lc.clearDisplay(0);
  //Serial.println("lv setup");
}

void writeArduinoOnMatrix() 
{
  //Serial.println("wAOM");
  /* now display them one by one with a small delay */
  lc.setRow(0,4,a[4]);
  lc.setRow(0,3,a[3]);
  lc.setRow(0,2,a[2]);
  lc.setRow(0,1,a[1]);
  lc.setRow(0,0,a[0]);
  delay(delaytime);
  lc.setRow(0,4,r[4]);
  lc.setRow(0,3,r[3]);
  lc.setRow(0,2,r[2]);
  lc.setRow(0,1,r[1]);
  lc.setRow(0,0,r[0]);
  delay(delaytime);
  lc.setRow(0,4,d[4]);
  lc.setRow(0,3,d[3]);
  lc.setRow(0,2,d[2]);
  lc.setRow(0,1,d[1]);
  lc.setRow(0,0,d[0]);
  delay(delaytime);
  lc.setRow(0,4,u[4]);
  lc.setRow(0,3,u[3]);
  lc.setRow(0,2,u[2]);
  lc.setRow(0,1,u[1]);
  lc.setRow(0,0,u[0]);
  delay(delaytime);
  lc.setRow(0,4,i[4]);
  lc.setRow(0,3,i[3]);
  lc.setRow(0,2,i[2]);
  lc.setRow(0,1,i[1]);
  lc.setRow(0,0,i[0]);
  delay(delaytime);
  lc.setRow(0,4,n[4]);
  lc.setRow(0,3,n[3]);
  lc.setRow(0,2,n[2]);
  lc.setRow(0,1,n[1]);
  lc.setRow(0,0,n[0]);
  delay(delaytime);
  lc.setRow(0,4,o[4]);
  lc.setRow(0,3,o[3]);
  lc.setRow(0,2,o[2]);
  lc.setRow(0,1,o[1]);
  lc.setRow(0,0,o[0]);
  delay(delaytime);
  lc.setRow(0,4,0);
  lc.setRow(0,3,0);
  lc.setRow(0,2,0);
  lc.setRow(0,1,0);
  lc.setRow(0,0,0);
  delay(delaytime);
}

void rows() 
{
  for(row=0;row<8;row++) 
  {
    delay(delaytime2);
    lc.setRow(0,row,B10100000);
    delay(delaytime2);
    lc.setRow(0,row,(byte)0);
    for(int i=0;i<row;i++) 
    {
      delay(delaytime2);
      lc.setRow(0,row,B10100000);
      delay(delaytime2);
      lc.setRow(0,row,(byte)0);
    }
  }
}

void columns() 
{
  for(col=0;col<8;col++) 
  {
    delay(delaytime2);
    lc.setColumn(0,col,B10100000);
    delay(delaytime2);
    lc.setColumn(0,col,(byte)0);
    for(int i=0;i<col;i++) 
    {
      delay(delaytime2);
      lc.setColumn(0,col,B10100000);
      delay(delaytime2);
      lc.setColumn(0,col,(byte)0);
    }
  }
}

void single() 
{
  for(row=0;row<8;row++) 
  {
    for(col=0;col<8;col++) 
    {
      delay(delaytime2);
      lc.setLed(0,row,col,true);
      delay(delaytime2);
      for(int i=0;i<col;i++) 
      {
        lc.setLed(0,row,col,false);
        delay(delaytime2);
        lc.setLed(0,row,col,true);
        delay(delaytime2);
      }
    }
  }
}

void eachdot ()
{
  //Serial.println("eachdot");
  for (row = 0; row < 8; row ++)
  {
    for(col = 0; col < 8; col ++)
    {
      lc.setLed(0,row,col,true);
      delay(delaytime2);
      lc.setLed(0,row,col,false);
    }
  }
}

void loop() 
{ 
  lc.setIntensity(0,2);
  writeArduinoOnMatrix();
}

I found something that does work --

//  ESP8266_max7219_demoworks
//  https://microcontrollerslab.com/max7219-led-dot-matrix-display-esp8266-nodemcu-tutorial/
//

#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>

// Uncomment according to your hardware type
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
//#define HARDWARE_TYPE MD_MAX72XX::GENERIC_HW

#define MAX_DEVICES 1
#define CS_PIN 15

// DATA (DIN) D7  13  SPI.h
// CLK        D5  14  SPI.h
// CS         D8  15

MD_Parola Display = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);

void setup() 
{
  Display.begin();
  Display.setIntensity(0);
  Display.displayClear();
  Display.displayScroll("E S P ", PA_RIGHT, PA_SCROLL_LEFT, 150);
}

void loop() 
{
  if (Display.displayAnimate()) 
  {
    Display.displayReset();
  }
}

1 Like

@naivekook,

Your topic was moved to its current location as it is more suitable.

Could you also take a few moments to Learn How To Use The Forum.

It will help you get the best out of the forum in the future.

Thank you

I'm dithering around with this myself at the moment. I think you will be better off with the MAX6951, as it is designed for 3.3v operation.
There is mention of this in the various 7221 blurbs around.

It's not anything to do with 3V3 - it's the LedControl library, it's not 8266 compatable.
Post No.6 is the answer - works as advertised.

I think that all the delays in the code supplied by OP cause the wdt to trigger. Have you tried disabling the wdt?

Aren't you (marco_c) the "Parola guy"? You're a maven there IIRC.

No. I tried slipping in some yield() where I thought they'd do some good (didn't find the right place).
I thought, perhaps mistakenly, that delay() can substitute for yield() in keeping the wdt happy (with millis() waits a yield() is necessary).
Be that as it may, or may not, it never begins setup(). I put an "I Got Here" to serial.print there, but I never saw that occur.

Anyway, the MD_Parola / MD_MAX72xx works great. And you don't have to make arrays for the letters --
Display.displayScroll("E S P ", PA_RIGHT, PA_SCROLL_LEFT, 150);
makes that go great.

@runaway_pancake Whoa! Thank you so much for the help! I really appreciate the time you spent helping another newbie :stuck_out_tongue_winking_eye:

It works with the MD_Parola library and I can continue my pet project :tada:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.