Wemos D1 mini/ MAX7219 problem

Hello,
I want to make a live subscriber count for youtube I have everything working all variables(image in attachments) are good but I can't print it to the display(MAX7219).

#include <YoutubeApi.h>
#include "LedControl.h"

/*******************************************************************
 *  An example of bot that echos back any messages received        *
 *                                                                 *
 *  written by Giacarlo Bacchio (Gianbacchio on Github)            *
 *  adapted by Brian Lough                                         *
 *******************************************************************/


#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>

//------- Replace the following! ------
char ssid[] = "xxxx";       // your network SSID (name)
char password[] = "xxxx";  // your network key
#define API_KEY "xxxxx"  // your google apps API Token
#define CHANNEL_ID "xxxxx" // makes up the url of channel


LedControl lc = LedControl(5, 4, 2, 1);


WiFiClientSecure client;
YoutubeApi api(API_KEY, client);

unsigned long api_mtbs = 60000; //mean time between api requests
unsigned long api_lasttime;   //last time api request has been done

long subs = 0;
long int countnumber=0;
int  firstnum=0;
int  secondnum=0;
int  thirdnum=0;
int  fournum=0;
int  fivenum=0;
int  sixnum=0;
int  sevennum=0;
int  eightnum=0;

void setup() {
 // Initialize the MAX7219 device
  lc.shutdown(0, false); // Enable display
  lc.setIntensity(0, 8); // Set brightness level (0 is min, 15 is max)
  lc.clearDisplay(0); // Clear dsplay register
  Serial.begin(115200);

  // Set WiFi to station mode and disconnect from an AP if it was Previously
  // connected
  WiFi.mode(WIFI_STA);
  WiFi.disconnect();
  delay(100);

  // Attempt to connect to Wifi network:
  Serial.print("Connecting Wifi: ");
  Serial.println(ssid);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  IPAddress ip = WiFi.localIP();
  Serial.println(ip);




}

void loop() {
    countnumber=api.channelStats.subscriberCount;
     if (countnumber > 9999999) {
    firstnum = ((countnumber/10000000)%10);
    secondnum = countnumber/1000000%10;
    thirdnum = countnumber/100000%10;
    fournum = countnumber/10000%10;
    fivenum = countnumber/1000%10;
    sixnum = countnumber/100%10;
    sevennum = countnumber/10%10;
    eightnum = countnumber%10;

    lc.setDigit(0,7,firstnum,false);
    lc.setDigit(0,6,secondnum,false);
    lc.setDigit(0,5,thirdnum,false);
    lc.setDigit(0,4,fournum,false);
    lc.setDigit(0,3,fivenum,false);
    lc.setDigit(0,2,sixnum,false);
    lc.setDigit(0,1,sevennum,false);
    lc.setDigit(0,0,eightnum,false);    
  }
    else {
      if (countnumber > 999999) {
//      firstnum = ((countnumber/10000000)%10);
        secondnum = countnumber/1000000%10;
        thirdnum = countnumber/100000%10;
        fournum = countnumber/10000%10;
        fivenum = countnumber/1000%10;
        sixnum = countnumber/100%10;
        sevennum = countnumber/10%10;
        eightnum = countnumber%10;

        lc.setChar(0,7,'-',false);
        lc.setDigit(0,6,secondnum,false);
        lc.setDigit(0,5,thirdnum,false);
        lc.setDigit(0,4,fournum,false);
        lc.setDigit(0,3,fivenum,false);
        lc.setDigit(0,2,sixnum,false);
        lc.setDigit(0,1,sevennum,false);
        lc.setDigit(0,0,eightnum,false);
      }   
        else {
          if (countnumber > 99999) {
//          firstnum = ((countnumber/10000000)%10);
//          secondnum = countnumber/1000000%10;
            thirdnum = countnumber/100000%10;
            fournum = countnumber/10000%10;
            fivenum = countnumber/1000%10;
            sixnum = countnumber/100%10;
            sevennum = countnumber/10%10;
            eightnum = countnumber%10;

            lc.setChar(0,7,'-',false);
            lc.setChar(0,6,'-',false);
            lc.setDigit(0,5,thirdnum,false);
            lc.setDigit(0,4,fournum,false);
            lc.setDigit(0,3,fivenum,false);
            lc.setDigit(0,2,sixnum,false);
            lc.setDigit(0,1,sevennum,false);
            lc.setDigit(0,0,eightnum,false);
          }
            else {
              if (countnumber > 9999) {
 //             firstnum = ((countnumber/10000000)%10);
 //             secondnum = countnumber/1000000%10;
 //             thirdnum = countnumber/100000%10;
                fournum = countnumber/10000%10;
                fivenum = countnumber/1000%10;
                sixnum = countnumber/100%10;
                sevennum = countnumber/10%10;
                eightnum = countnumber%10;

                lc.setChar(0,7,'-',false);
                lc.setChar(0,6,'-',false);
                lc.setChar(0,5,'-',false);
                lc.setDigit(0,4,fournum,false);
                lc.setDigit(0,3,fivenum,false);
                lc.setDigit(0,2,sixnum,false);
                lc.setDigit(0,1,sevennum,false);
                lc.setDigit(0,0,eightnum,false);
              } 
              else {
                if (countnumber > 999) {
  //              firstnum = ((countnumber/10000000)%10);
  //              secondnum = countnumber/1000000%10;
  //              thirdnum = countnumber/100000%10;
  //              fournum = countnumber/10000%10;
                  fivenum = countnumber/1000%10;
                  sixnum = countnumber/100%10;
                  sevennum = countnumber/10%10;
                  eightnum = countnumber%10;
  
                  lc.setChar(0,7,'-',false);
                  lc.setChar(0,6,'-',false);
                  lc.setChar(0,5,'-',false);
                  lc.setChar(0,4,'-',false);
                  lc.setDigit(0,3,fivenum,false);
                  lc.setDigit(0,2,sixnum,false);
                  lc.setDigit(0,1,sevennum,false);
                  lc.setDigit(0,0,eightnum,false);
                }
                else {
  //              firstnum = ((countnumber/10000000)%10);
  //              secondnum = countnumber/1000000%10;
  //              thirdnum = countnumber/100000%10;
  //              fournum = countnumber/10000%10;
  //              fivenum = countnumber/1000%10;
                  sixnum = countnumber/100%10;
                  sevennum = countnumber/10%10;
                  eightnum = countnumber%10;
  
                  lc.setChar(0,7,'-',false);
                  lc.setChar(0,6,'-',false);
                  lc.setChar(0,5,'-',false);
                  lc.setChar(0,4,'-',false);
                  lc.setChar(0,3,'-',false);
                  lc.setDigit(0,2,sixnum,false);
                  lc.setDigit(0,1,sevennum,false);
                  lc.setDigit(0,0,eightnum,false);
             }
               
            }
          }
        } 
      }
    if (millis() - api_lasttime > api_mtbs)  {
    if(api.getChannelStatistics(CHANNEL_ID))
    {
      Serial.println("---------Stats---------");
      Serial.print("Subscriber Count: ");
      Serial.println(api.channelStats.subscriberCount);
      Serial.print("View Count: ");
      Serial.println(api.channelStats.viewCount);
      Serial.print("Comment Count: ");
      Serial.println(api.channelStats.commentCount);
      Serial.print("Video Count: ");
      Serial.println(api.channelStats.videoCount);
      // Probably not needed :)
      //Serial.print("hiddenSubscriberCount: ");
      //Serial.println(api.channelStats.hiddenSubscriberCount);
      Serial.println("------------------------");
      countnumber=api.channelStats.subscriberCount;
      Serial.println(countnumber);
      Serial.println(firstnum);
      Serial.println(secondnum);
      Serial.println(thirdnum);
      Serial.println(fournum);
      Serial.println(fivenum);
      Serial.println(sixnum);
      Serial.println(sevennum);
      Serial.println(eightnum);
      
    }
    api_lasttime = millis();
  }
   
}

I had some problems with the LedControl lib so I had to change #include "WConstants.h" to Arduino.h
I tried a code that works on the Arduino mega but not in the Wemos
I'm not the best coder i only know somethings.
Be happy and have a great day :smiley:

What do you mean by "can't print it to the display"? Do you mean that the code you posted compiles and uploads fine and displays the correct numbers in the Serial Monitor but nothing appears on the MAX7219 display?

What happens if you try a minimal sketch that only prints "hello world" to the display without all the extra complications?

LedControl lc = LedControl(5, 4, 2, 1);

Which Wemos pins did you connect to the max chip?

Maybe you should use

LedControl lc = LedControl(D5, D4, D2, D1);