16x32 LED Matrix Turning on LEDs Randomly

Hello forensics. I hope you are all well.

As I wrote in the title, I have a Clock code for a 16x32 Bicolor LED Matrix, which is partially working. I say partially because, in the upper part of this matrix (in red), it shows a clock, and in the lower part (in green), it shows a scrolling text, however, there are some ghost LEDs, if I can say so. To explain: While in the upper part 7 red LEDs light up vertically (Hours), in the lower part, 7 green LEDs light up vertically (Scrolling) but, together with these LEDs scrolling in the lower part, they show a weak line of green LEDs scrolling, invading the upper part of the screen (red), in a ghostly way but, lighting up very weakly, mainly during the day; at night, it highlights a little more.

The pin connections are correct, as mentioned in the code itself. Furthermore, the project also uses a DS3231, and I am powering everything with a 5V 2A Wall Power Supply.
I am making the code available for anyone who may be able to spot an error in it.
I would be very grateful for any help.

#include "myMATRIX.h"

#define RowA_Pin 2
#define RowB_Pin 3
#define RowC_Pin 4
#define RowD_Pin 5
#define OE_Pin 9
#define Red_Pin 8
#define Green_Pin 7
#define CLK_Pin 12
#define STB_Pin 11

unsigned long previousMillis = 0;
unsigned long scroll_previousMillis = 0;
const long interval = 500;
const long scroll_interval = 60;
byte colonState = LOW;

#include <Wire.h>
#include "RTClib.h"
#include<TimeLib.h>

char timeString[] = "00:00";
char seconds = 0;
RTC_DS3231 rtc;

char scrolltext_1[] = "       Sandra e Daniel      ";
uint32_t syncProvider()
{
  return rtc.now().unixtime();
}

void setup ()
{

  if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    while (1);
  }
  setSyncProvider(syncProvider);
  setSyncInterval(1800);
  if (rtc.lostPower()) {
    Serial.println("RTC lost power, lets set the time!");
    // A seguinte linha define o RTC para a Data e Hora em que este sketch foi compilado.
    // rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
    // Esta linha define o RTC com uma Data e Hora explícitas; por exemplo, para definir
    // Janeiro 21, 2014 em 3AM, você deve chamar:
    // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
  }

  myMatrix.Init(Red_Pin, Green_Pin, CLK_Pin, RowA_Pin, RowB_Pin, RowC_Pin, RowD_Pin, OE_Pin, STB_Pin);
  myMatrix.clearScreen();

}

void loop()
{
  unsigned long currentMillis = millis();
  unsigned long scroll_currentMillis = millis();


  if (currentMillis - previousMillis >= interval)
  {
    previousMillis = currentMillis;

    if (colonState == LOW)
    {
      colonState = HIGH;
      sprintf(timeString, "%02d:%02d", hour(), minute());
      myMatrix.printString(1, 0, green, black, timeString);
    }
    else
    {
      colonState = LOW;
      sprintf(timeString, "%02d %02d", hour(), minute());
      myMatrix.printString(1, 0, green, black, timeString);
    }
  }
  if (scroll_currentMillis - scroll_previousMillis >=  scroll_interval)
  {
    myMatrix.hScroll_nb(9, red, black, scrolltext_1);
    scroll_previousMillis = scroll_currentMillis;
  }

}

In this row of LEDs, where I pointed with the arrow (red), some ghost LEDs appear.

Did you make this library or did you download it? Either way, please provide the code or a link to the library.

The zip file here seems to be working with the rows of 8x8 panels.https://www.instructables.com/32x16-LED-Matrix-Panel-and-Arduino/

/*
File	: myMATRIX.h
Version	: 1.0
Date	: 14.01.2015
Project	: myMatrix Arduino Library

The MIT License (MIT)

Copyright (c) 2015 Silviu - www.openhardware.ro

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

#ifndef myMATRIX_h
  #define myMATRIX_h
  #include "myMATRIXClass.h"

  myMATRIX myMatrix;
  #if defined(newTimer2)  
    ISR(TIMER2_COMPA_vect)
    { 
      myMatrix.Show();
    }
  #endif
  #if defined(oldTimer2)
    ISR(TIMER2_COMP_vect)
    {
      myMatrix.Show();
    }
  #endif
#endif
/*
File	: myMATRIXclass.h
Version	: 1.0
Date	: 14.01.2015
Project	: myMatrix Arduino Library

The MIT License (MIT)

Copyright (c) 2015 Silviu - www.openhardware.ro

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

// ensure this library description is only included once
#ifndef myMATRIXClass_h
#define myMATRIXClass_h

  #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
   || defined(__AVR_ATmega644__)  || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) \
   || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega88P__)  || defined(__AVR_ATmega48P__) 
    #define newTimer2
  #endif
  #if defined(__AVR_ATmega32__) || defined(__AVR_ATmega8__) || defined(__AVR_ATmega64__)
    #define oldTimer2  
  #endif  


#include <avr/pgmspace.h>

#if ARDUINO < 100
#include "wiring.h"
#else
#include "Arduino.h"
#endif
	
#include "font5x7.h"

#define black  0
#define green  1
#define red    2
#define yellow 3


// library interface description
class myMATRIX
{
  // user-accessible "public" interface
  public:
    volatile byte matrixBufferRed[64];   
    volatile byte matrixBufferGreen[64];  

    myMATRIX();
    void Init(uint8_t pinRed, uint8_t pinGreen, uint8_t pinClock, 
                 uint8_t pinRowA, uint8_t pinRowB, uint8_t pinRowC, uint8_t pinRowD,
                 uint8_t pinOE, uint8_t pinSTB);

    void setPixel(uint8_t x ,uint8_t y, uint8_t color);
    void fillRectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint8_t color);
    void drawRectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint8_t color);
    void clearScreen();
    void printChar(uint8_t x,uint8_t y, uint8_t For_color, uint8_t Bk_color, char ch);
    void printString(uint8_t x, uint8_t y, uint8_t For_color, uint8_t Bk_color,char *p);
    void drawVLine(uint16_t x, uint16_t y1, uint16_t y2, uint8_t color);
    void drawHLine(uint16_t x1, uint16_t x2, uint16_t y, uint8_t color);
    void hScroll(uint8_t y, uint8_t For_color, uint8_t Bk_color,char *p);
    void Show();
// library-accessible "private" interface
  private:
    byte row; 
    volatile uint8_t *outRed;
    volatile uint8_t *outGreen;
    volatile uint8_t *outClock;
    volatile uint8_t *outRowA;
    volatile uint8_t *outRowB;
    volatile uint8_t *outRowC;
    volatile uint8_t *outRowD;
    volatile uint8_t *outOE;
    volatile uint8_t *outSTB;
    
    uint8_t bitRed;
    uint8_t bitGreen;
    uint8_t bitClock;
    uint8_t bitRowA;
    uint8_t bitRowB;
    uint8_t bitRowC;
    uint8_t bitRowD;
    uint8_t bitOE;
    uint8_t bitSTB;
   
    void t_shiftOut(uint8_t dataRed,uint8_t dataGreen);    
    void rowScan(byte row);
    byte getPixelChar(uint8_t x, uint8_t y1, char ch);
    byte getPixelHString(uint16_t x, uint16_t y, char *p);
    void timer2Setup(void);
};

unsigned int lenString(char *p);

#endif
/*
File	: myMATRIXclass.cpp
Version	: 1.0
Date	: 14.01.2015
Project	: myMatrix Arduino Library

The MIT License (MIT)

Copyright (c) 2015 Silviu - www.openhardware.ro

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

#if ARDUINO < 100
#include "WProgram.h" // include core Wiring API
#endif

// include this library's description file
#include "myMATRIXclass.h"

// include description files for other libraries used (if any)
//#include "HardwareSerial.h"

// Constructor /////////////////////////////////////////////////////////////////
// Function that handles the creation and setup of instances
myMATRIX::myMATRIX()
{

}

// Public Methods //////////////////////////////////////////////////////////////

void myMATRIX::Init(uint8_t pinRed, uint8_t pinGreen, uint8_t pinClock, 
          uint8_t pinRowA, uint8_t pinRowB, uint8_t pinRowC, uint8_t pinRowD,
          uint8_t pinOE, uint8_t pinSTB)

{
  row = 0;
  pinMode(pinRed, OUTPUT); 
  pinMode(pinGreen, OUTPUT); 
  pinMode(pinClock, OUTPUT); 
  pinMode(pinRowA, OUTPUT); 
  pinMode(pinRowB, OUTPUT); 
  pinMode(pinRowC, OUTPUT); 
  pinMode(pinRowD, OUTPUT); 
  pinMode(pinOE, OUTPUT); 
  pinMode(pinSTB, OUTPUT); 
  
  bitRed = digitalPinToBitMask(pinRed);
  uint8_t portRed = digitalPinToPort(pinRed);
  outRed = portOutputRegister(portRed);

  bitGreen = digitalPinToBitMask(pinGreen);
  uint8_t portGreen = digitalPinToPort(pinGreen);
  outGreen = portOutputRegister(portGreen);

  bitClock = digitalPinToBitMask(pinClock);
  uint8_t portClock = digitalPinToPort(pinClock);
  outClock = portOutputRegister(portClock);

  bitRowA = digitalPinToBitMask(pinRowA);
  uint8_t portRowA = digitalPinToPort(pinRowA);
  outRowA = portOutputRegister(portRowA);

  bitRowB = digitalPinToBitMask(pinRowB);
  uint8_t portRowB = digitalPinToPort(pinRowB);
  outRowB = portOutputRegister(portRowB);

  bitRowC = digitalPinToBitMask(pinRowC);
  uint8_t portRowC = digitalPinToPort(pinRowC);
  outRowC = portOutputRegister(portRowC);

  bitRowD = digitalPinToBitMask(pinRowD);
  uint8_t portRowD = digitalPinToPort(pinRowD);
  outRowD = portOutputRegister(portRowD);

  bitOE = digitalPinToBitMask(pinOE);
  uint8_t portOE = digitalPinToPort(pinOE);
  outOE = portOutputRegister(portOE);

  bitSTB = digitalPinToBitMask(pinSTB);
  uint8_t portSTB = digitalPinToPort(pinSTB);
  outSTB = portOutputRegister(portSTB);

  clearScreen(); // clear buffer
  timer2Setup();
}

void myMATRIX::setPixel(uint8_t x ,uint8_t y, uint8_t color) //color 2 Bit, (R)ed (G)reen 0b000000RG
{
  
  uint8_t myindex = (y*4)+x/8;
  uint8_t mybitmask = 7 -(x % 8);
  if (color & 0b00000010) // red
  {
    bitWrite(matrixBufferRed[myindex],mybitmask,1);
  }
  else
  {
    bitWrite(matrixBufferRed[myindex],mybitmask,0);
  }
  if (color & 0b00000001) //green
  {
    bitWrite(matrixBufferGreen[myindex],mybitmask,1);
  }
  else
  {
    bitWrite(matrixBufferGreen[myindex],mybitmask,0);
  }  
}


void myMATRIX::fillRectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint8_t color)
{
    for (uint16_t x = x1; x <= x2; x++) {
        for (uint16_t y = y1; y <= y2; y++) {
            setPixel(x,y,color);      
        }
    }
}
void myMATRIX::drawRectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint8_t color)
{
    drawHLine(x1,x2,y1,color);
    drawHLine(x1,x2,y2,color);  
    drawVLine(x1,y1,y2,color);
    drawVLine(x2,y1,y2,color);
}

void myMATRIX::drawVLine(uint16_t x, uint16_t y1, uint16_t y2, uint8_t color)
{
    for (uint16_t y = y1; y <= y2; y++) {
        setPixel(x,y,color);      
    }
}

void myMATRIX::drawHLine(uint16_t x1, uint16_t x2, uint16_t y, uint8_t color)
{
    for (uint16_t x = x1; x <= x2; x++) {
          setPixel(x,y,color);      
    }  
}
void myMATRIX::clearScreen()
{
    for (uint8_t i=0; i<64; i++)
    {
      matrixBufferRed[i]=0;
      matrixBufferGreen[i]=0; 
    }
}

void myMATRIX::printChar(uint8_t x,uint8_t y, uint8_t For_color, uint8_t Bk_color, char ch)
{
  uint8_t xx,yy;
  xx=0;
  yy=0;
  ch = ch-32;
  for (yy=0; yy < 7; yy++)
  {
    for (xx=0; xx < 5; xx++)
    {
      if (bitRead(pgm_read_byte(&font5x7[ch][yy]),4-xx)) // 4 == Font witdh -1
      
      {
        setPixel(x+xx,y+yy,For_color);
      }
      else
      {
        setPixel(x+xx,y+yy,Bk_color);        
      }
    }
  }  
}

void myMATRIX::printString(uint8_t x, uint8_t y, uint8_t For_color, uint8_t Bk_color,char *p)
{         
   while(*p!='\0')
   {       
     printChar(x,y,For_color,Bk_color,*p);
     x+=6; // 6 = font width + 1 pixel space
     p++;
   }
}

void myMATRIX::hScroll(uint8_t y, uint8_t For_color, uint8_t Bk_color,char *mystring)
{
  int offset =0;
  
  for (offset=0; offset <((lenString(mystring)-5)*6-1); offset++)
  {
  for (byte xx=0; xx<32; xx++)
  {
    for (byte yy=0; yy<7; yy++)
    {
      byte color;
      if (getPixelHString(xx+offset,yy,mystring)) color = For_color; else color=Bk_color;
      setPixel(xx,yy+y,color);
    }
  }
  delay(50);  
  }
}

// Private Methods /////////////////////////////////////////////////////////////

void myMATRIX::t_shiftOut(uint8_t dataRed,uint8_t dataGreen)
{
    uint8_t i;
    uint8_t val;
    for (i = 0; i<8; i++)  
    {
      val = !!(dataRed & (1 << (7 - i)));
      if (val) *outRed |= bitRed;
          else *outRed &= ~bitRed;            
      
      val = !!(dataGreen & (1 << (7 - i)));
      if (val) *outGreen |= bitGreen;
	  else *outGreen &= ~bitGreen;
	                        
      //Clock Pulse
      *outClock |= bitClock; //CLK, HIGH
      *outClock &= ~bitClock; //CLK, LOW               		
    }
}

void myMATRIX::rowScan(byte row)
{
  if (row & 0x01) *outRowA |= bitRowA;
    else *outRowA &= ~bitRowA;
  
  if (row & 0x02) *outRowB |= bitRowB;
    else *outRowB &= ~bitRowB;

  if (row & 0x04) *outRowC |= bitRowC;
    else *outRowC &= ~bitRowC;

  if (row & 0x08) *outRowD |= bitRowD;
    else *outRowD &= ~bitRowD;
}  

void myMATRIX::Show()
{
  //for (byte row=0; row<16; row++)
  //{
    byte row4=row*4;
    *outOE |= bitOE; //OE HIGH => screen OFF
    t_shiftOut(~(matrixBufferRed[row4]),~(matrixBufferGreen[row4])); 
    t_shiftOut(~(matrixBufferRed[(row4)+1]),~(matrixBufferGreen[(row4)+1]));
    t_shiftOut(~(matrixBufferRed[(row4)+2]),~(matrixBufferGreen[(row4)+2])); 
    t_shiftOut(~(matrixBufferRed[(row4)+3]),~(matrixBufferGreen[(row4)+3]));
    rowScan(row);
    *outSTB &= ~bitSTB; //STB LOW 
    *outSTB |= bitSTB; //STB HIGH ... high to copy shift register's data to output 
    //delayMicroseconds(7); //???;
    *outOE &= ~bitOE; //OE LOW => screen ON
    //delayMicroseconds(500);
  //} 
    row++;
    if (row==16) row=0;
}

byte myMATRIX::getPixelChar(uint8_t x, uint8_t y, char ch)
{
    ch = ch-32;
   if (x > 4) return 0; // 4 = font Width -1
   return bitRead(pgm_read_byte(&font5x7[ch][y]),4-x); // 4 = Font witdh -1  
}

byte myMATRIX::getPixelHString(uint16_t x, uint16_t y, char *p)
{
  p=p+x/6;
  return getPixelChar(x%6,y,*p);
}


void myMATRIX::timer2Setup()
{
#if defined(newTimer2) 
  TCCR2A = 0;
  TCCR2B = 0;
  TCNT2  = 0;
  OCR2A = 254;
  TCCR2A |= (1 << WGM21);
  TCCR2B |= (1 << CS22);    
  TIMSK2 |= (1 << OCIE2A);  
#endif
#if defined(oldTimer2)
    TCCR2=0;
    TCNT2=0;
    OCR2 = 254;
    TCCR2|= (1 << WGM21);
    TCCR2|=(1 << CS22);
    TIMSK|=(1<<OCIE2);
    TCNT2=0;
#endif

}

// Other Functions //////////////////////////////////////////////////////////////
unsigned int lenString(char *p)
{
  unsigned int retVal=0;
  while(*p!='\0')
  { 
   retVal++;
   p++;
  }
  return retVal;
}
/*
File	: font5x7.h
Version	: 1.0
Date	: 14.01.2015
Project	: myMatrix Arduino Library

The MIT License (MIT)

Copyright (c) 2015 Silviu - www.openhardware.ro

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

#ifndef FONT5X7_H
#define FONT5X7_H

//static const uint8_t font5x7[96][7] =
static const uint8_t font5x7[96][7] PROGMEM =
{
{
  0B00000, // Space [0]
  0B00000,
  0B00000,
  0B00000,
  0B00000,
  0B00000,
  0B00000},
{
  0B00100, // ! [1]
  0B00100,
  0B00100,
  0B00100,
  0B00100,
  0B00000,
  0B00100},
{
  0B01010, // " [2]
  0B01010,
  0B00000,
  0B00000,
  0B00000,
  0B00000,
  0B00000},
{
  0B00000, // # [3]
  0B01010,
  0B11111,
  0B01010,
  0B11111,
  0B01010,
  0B00000},
{
  0B01110, // $ [4]
  0B10101,
  0B10100,
  0B01110,
  0B00101,
  0B10101,
  0B01110},
{
  0B11000, // % [5]
  0B11001,
  0B00010,
  0B00100,
  0B01000,
  0B10011,
  0B00011},
{
  0B00110, // & [6]
  0B01010,
  0B00100,
  0B01101,
  0B10010,
  0B10011,
  0B01110},
{
  0B00100, // ' [7]
  0B00100,
  0B00000,
  0B00000,
  0B00000,
  0B00000,
  0B00000},
{
  0B00010, // ( [8]
  0B00100,
  0B00100,
  0B00100,
  0B00100,
  0B00100,
  0B00010},  
{
  0B01000, // ) [9]
  0B00100,
  0B00100,
  0B00100,
  0B00100,
  0B00100,
  0B01000},  
{
  0B00100, // * [10]
  0B10101,
  0B01110,
  0B01110,
  0B10101,
  0B00100,
  0B00000},
{
  0B00000, // + [11]
  0B00100,
  0B00100,
  0B11111,
  0B00100,
  0B00100,
  0B00000},
{
  0B00000, // , [12]
  0B00000,
  0B00000,
  0B00000,
  0B00000,
  0B00100,
  0B00100},
{
  0B00000, // - [13]
  0B00000,
  0B00000,
  0B11111,
  0B00000,
  0B00000,
  0B00000},
{
  0B00000, // . [14]
  0B00000,
  0B00000,
  0B00000,
  0B00000,
  0B00000,
  0B00100},
{
  0B00000, // / [15]
  0B00001,
  0B00010,
  0B00100,
  0B01000,
  0B10000,
  0B00000},
{
  0B01110, // 0 [16]
  0B10001,
  0B10011,
  0B10101,
  0B11001,
  0B10001,
  0B01110},
{
  0B00100, // 1 [17]
  0B01100,
  0B10100,
  0B00100,
  0B00100,
  0B00100,
  0B11111},
{
  0B01110, // 2 [18]
  0B10001,
  0B00010,
  0B00100,
  0B01000,
  0B10000,
  0B11111},
{
  0B01110, // 3 [19]
  0B10001,
  0B00001,
  0B00110,
  0B00001,
  0B10001,
  0B01110},
{
  0B10010, // 4 [20]
  0B10010,
  0B10010,
  0B11111,
  0B00010,
  0B00010,
  0B00010},
{
  0B11111, // 5 [21]
  0B10000,
  0B10000,
  0B11110,
  0B00001,
  0B00001,
  0B11110},
{
  0B01110, // 6 [22]
  0B10000,
  0B10000,
  0B11110,
  0B10001,
  0B10001,
  0B01110},
{
  0B11111, // 7 [23]
  0B00001,
  0B00001,
  0B00010,
  0B00100,
  0B00100,
  0B00100},
{
  0B01110, // 8 [24]
  0B10001,
  0B10001,
  0B01110,
  0B10001,
  0B10001,
  0B01110},
{
  0B01110, // 9 [25]
  0B10001,
  0B10001,
  0B01111,
  0B00001,
  0B10001,
  0B01110},
{
  0B00000, // : [26]
  0B00000,
  0B00100,
  0B00000,
  0B00100,
  0B00000,
  0B00000},
{
  0B00000, // ; [27]
  0B00000,
  0B00100,
  0B00000,
  0B00100,
  0B01000,
  0B00000},
{
  0B00011, // < [28]
  0B00100,
  0B01000,
  0B10000,
  0B01000,
  0B00100,
  0B00011},
{
  0B00000, // = [29]
  0B00000,
  0B11111,
  0B00000,
  0B11111,
  0B00000,
  0B00000},
{
  0B11000, // > [30]
  0B00100,
  0B00010,
  0B00001,
  0B00010,
  0B00100,
  0B11000},
{
  0B01110, // ? [31]
  0B10001,
  0B00001,
  0B00110,
  0B00100,
  0B00000,
  0B00100},
{
  0B01110, // @ [32]
  0B10001,
  0B10011,
  0B10011,
  0B10000,
  0B10001,
  0B01110},
{
  0B01110, // A [33]
  0B10001,
  0B10001,
  0B11111,
  0B10001,
  0B10001,
  0B10001},
{
  0B11110, // B [34]
  0B10001,
  0B10001,
  0B11110,
  0B10001,
  0B10001,
  0B11110},
{
  0B01110, // C [35]
  0B10001,
  0B10000,
  0B10000,
  0B10000,
  0B10001,
  0B01110},
{
  0B11110, // D [36]
  0B10001,
  0B10001,
  0B10001,
  0B10001,
  0B10001,
  0B11110},
{
  0B11111, // E [37]
  0B10000,
  0B10000,
  0B11100,
  0B10000,
  0B10000,
  0B11111},
{
  0B11111, // F [38]
  0B10000,
  0B10000,
  0B11100,
  0B10000,
  0B10000,
  0B10000},
{
  0B01110, // G [39]
  0B10001,
  0B10000,
  0B10000,
  0B10011,
  0B10001,
  0B01110},
{
  0B10001, // H [40]
  0B10001,
  0B10001,
  0B11111,
  0B10001,
  0B10001,
  0B10001},
{
  0B01110, // I [41]
  0B00100,
  0B00100,
  0B00100,
  0B00100,
  0B00100,
  0B01110},
{
  0B00001, // J [42]
  0B00001,
  0B00001,
  0B00001,
  0B00001,
  0B10001,
  0B01110},
{
  0B10001, // K [43]
  0B10010,
  0B10100,
  0B11000,
  0B10100,
  0B10010,
  0B10001},
{
  0B10000, // L[44]
  0B10000,
  0B10000,
  0B10000,
  0B10000,
  0B10000,
  0B11111},
{
  0B10001, // M [45]
  0B11011,
  0B10101,
  0B10001,
  0B10001,
  0B10001,
  0B10001},
{
  0B10001, // N [46]
  0B10001,
  0B11001,
  0B10101,
  0B10011,
  0B10001,
  0B10001},
{
  0B01110, // O [47]
  0B10001,
  0B10001,
  0B10001,
  0B10001,
  0B10001,
  0B01110},
{
  0B11110, // P
  0B10001,
  0B10001,
  0B11110,
  0B10000,
  0B10000,
  0B10000},
{
  0B01110, // Q
  0B10001,
  0B10001,
  0B10001,
  0B10101,
  0B10011,
  0B01111},
{
  0B11110, // R
  0B10001,
  0B10001,
  0B11110,
  0B10100,
  0B10010,
  0B10001},
{
  0B01110, // S
  0B10001,
  0B10000,
  0B01110,
  0B00001,
  0B10001,
  0B01110},
{
  0B11111, // T
  0B00100,
  0B00100,
  0B00100,
  0B00100,
  0B00100,
  0B00100},
{
  0B10001, // U
  0B10001,
  0B10001,
  0B10001,
  0B10001,
  0B10001,
  0B01110},
{
  0B10001, // V
  0B10001,
  0B10001,
  0B10001,
  0B10001,
  0B01010,
  0B00100},
{
  0B10001, // W
  0B10001,
  0B10001,
  0B10001,
  0B10101,
  0B10101,
  0B01010},
{
  0B10001, // X
  0B10001,
  0B01010,
  0B00100,
  0B01010,
  0B10001,
  0B10001},
{
  0B10001, // Y
  0B01010,
  0B00100,
  0B00100,
  0B00100,
  0B00100,
  0B00100},
{
  0B11111, // Z
  0B00001,
  0B00010,
  0B00100,
  0B01000,
  0B10000,
  0B11111},
{
  0B00110, // [
  0B00100,
  0B00100,
  0B00100,
  0B00100,
  0B00100,
  0B00110},
{
  0B00000, // \
  0B10000,
  0B01000,
  0B00100,
  0B00010,
  0B00001,
  0B00000},
{
  0B01100, // ]
  0B00100,
  0B00100,
  0B00100,
  0B00100,
  0B00100,
  0B01100},
{
  0B00100, // ^
  0B01010,
  0B10001,
  0B00000,
  0B00000,
  0B00000,
  0B00000},
{
  0B00000, // _
  0B00000,
  0B00000,
  0B00000,
  0B00000,
  0B00000,
  0B11111},
{
  0B00100, // `
  0B00100,
  0B00000,
  0B00000,
  0B00000,
  0B00000,
  0B00000},
{
  0B00000, // a
  0B00000,
  0B11100,
  0B00010,
  0B01110,
  0B10010,
  0B11111},
{
  0B10000, // b
  0B10000,
  0B10000,
  0B11110,
  0B10001,
  0B10001,
  0B11110},
{
  0B00000, // c
  0B00000,
  0B01110,
  0B10001,
  0B10000,
  0B10001,
  0B01110},
{
  0B00001, // d
  0B00001,
  0B00001,
  0B01111,
  0B10001,
  0B10001,
  0B01111},
{
  0B00000, // e
  0B00000,
  0B01110,
  0B10001,
  0B11111,
  0B10000,
  0B01111},
{
  0B01110, // f
  0B01001,
  0B01000,
  0B11100,
  0B01000,
  0B01000,
  0B01000},
{
  0B00000, // g
  0B00000,
  0B01110,
  0B10001,
  0B11111,
  0B00001,
  0B01110},
{
  0B10000, // h
  0B10000,
  0B10000,
  0B11110,
  0B10001,
  0B10001,
  0B10001},
{
  0B00000, // i
  0B00100,
  0B00000,
  0B01100,
  0B00100,
  0B00100,
  0B11111},
{
  0B00000, // j
  0B00010,
  0B00000,
  0B00110,
  0B00010,
  0B00010,
  0B11110},
{
  0B11000, // k
  0B01000,
  0B01000,
  0B01011,
  0B01100,
  0B01010,
  0B11001},
{
  0B01100, // l
  0B00100,
  0B00100,
  0B00100,
  0B00100,
  0B00100,
  0B11111},
{
  0B00000, // m
  0B00000,
  0B10001,
  0B11111,
  0B10101,
  0B10101,
  0B10101},
{
  0B00000, // n
  0B00000,
  0B10110,
  0B11001,
  0B10001,
  0B10001,
  0B10001},
{
  0B00000, // o
  0B00000,
  0B01110,
  0B10001,
  0B10001,
  0B10001,
  0B01110},
{
  0B00000, // p
  0B00000,
  0B11110,
  0B10001,
  0B11110,
  0B10000,
  0B10000},
{
  0B00000, // q
  0B00000,
  0B01111,
  0B10010,
  0B11110,
  0B00010,
  0B00011},
{
  0B00000, // r
  0B00000,
  0B10110,
  0B11001,
  0B10000,
  0B10000,
  0B10000},
{
  0B00000, // s
  0B00000,
  0B01111,
  0B10000,
  0B11110,
  0B00001,
  0B11110},
{
  0B00100, // t
  0B00100,
  0B11111,
  0B00100,
  0B00100,
  0B00100,
  0B00111},
{
  0B00000, // u
  0B00000,
  0B10001,
  0B10001,
  0B10001,
  0B10001,
  0B01111},
{
  0B00000, // v
  0B00000,
  0B10001,
  0B10001,
  0B10001,
  0B01010,
  0B00100},
{
  0B00000, // w
  0B00000,
  0B10001,
  0B10001,
  0B10101,
  0B11011,
  0B10001},
{
  0B00000, // x
  0B00000,
  0B10001,
  0B01010,
  0B00100,
  0B01010,
  0B10001},
{
  0B00000, // y
  0B00000,
  0B10001,
  0B10001,
  0B01111,
  0B00001,
  0B00111},
{
  0B00000, // z
  0B00000,
  0B11111,
  0B00010,
  0B00100,
  0B01000,
  0B11111},
{
  0B00110, // {
  0B00100,
  0B00100,
  0B01000,
  0B00100,
  0B00100,
  0B00110},
{
  0B00100, // |
  0B00100,
  0B00100,
  0B00100,
  0B00100,
  0B00100,
  0B00100},
{
  0B01100, // }
  0B00100,
  0B00100,
  0B00010,
  0B00100,
  0B00100,
  0B01100},
{
  0B00000, // unfinished
  0B00000,
  0B00000,
  0B00000,
  0B00000,
  0B00000,
  0B00000},
{
  0B00000, // unfinished
  0B00000,
  0B00000,
  0B00000,
  0B00000,
  0B00000,
  0B00000},
};

#endif
/*
File	: myMATRIX_Demo.pde
Version	: 1.0
Date	: 14.01.2015
Project	: myMatrix Arduino Library

The MIT License (MIT)

Copyright (c) 2015 Silviu - www.openhardware.ro

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/


/*
  Simple demo for <myMatrix> 16x32 Red Green LED Matrix Panel . 

  The circuit:
  A   connect to digital pin 2
  B   connect to digital pin 3
  C   connect to digital pin 4
  D   connect to digital pin 5
  OE  connect to digital pin 6
  R   connect to digital pin 7
  G   connect to digital pin 8
  CLK connect to digital pin 9
  STB connect to digital pin 10
  GND connect to GND
*/

#include "myMATRIX.h"

#define RowA_Pin 2
#define RowB_Pin 3
#define RowC_Pin 4
#define RowD_Pin 5 
#define OE_Pin 6  
#define Red_Pin 7  
#define Green_Pin 8  
#define CLK_Pin 9  
#define STB_Pin 10 

void setup () 
{
     myMatrix.Init(Red_Pin,Green_Pin,CLK_Pin,RowA_Pin,RowB_Pin,RowC_Pin,RowD_Pin,OE_Pin,STB_Pin); 
}    

void loop()
{
 myMatrix.clearScreen();
 char scrolltext_1[]="     * www.OpenHardware.Ro *      ";
 char scrolltext_2[]="     * Numbers * 1234567890      ";
 char scrolltext_3[]="     * Capital Letters * ABCDEFGHIJKLMNOPQRSTUVXYZ      ";
 char scrolltext_4[]="     * Small Letters * abcdefghijklmnopqrstuvxyz      ";
 myMatrix.fillRectangle(0,0,31,15,red);
 delay(1000);
 myMatrix.fillRectangle(0,0,31,15,green);
 delay(1000);
 myMatrix.fillRectangle(0,0,31,15,yellow);
 delay(1000);
 myMatrix.drawRectangle(0,0,31,15,red); 
 delay(1000);
 myMatrix.fillRectangle(10,3,21,12,green);
 delay(1000); 
 myMatrix.clearScreen();
 myMatrix.drawHLine(0,31,7,green);
 myMatrix.drawHLine(0,31,15,green);
 myMatrix.drawVLine(0,0,15,yellow);
 myMatrix.drawVLine(31,0,15,yellow);
 myMatrix.printString(5,8,yellow,black,"Demo");
 myMatrix.hScroll(0,red,black,scrolltext_1);
 myMatrix.hScroll(0,black,green,scrolltext_1);
 myMatrix.hScroll(0,red,black,scrolltext_2);
 myMatrix.hScroll(0,red,black,scrolltext_3);
 myMatrix.hScroll(0,red,black,scrolltext_4);
}

Yes Paul. The library is the same. It belongs to someone else; Silvius, if I'm not mistaken, and it's from that 'instructables' page that @xfpd showed in the link.

Verify the power supply is sufficient (32 x 16 = 512 LEDs * [edit] 20mA/LED = 10.24A when all LEDs are on and full bright). See post #7.

Verify all ground connections meet. Preferably in a start topology, not chained (front-to-back).

Moving the panel while energized will show if connections are good (steady LEDs) or intermittent (flickering, fading, VERY bright).

No, 1/16th of that. It's a multiplexed matrix.

1 Like

That's not reassuring at all.

I can't immediately see a problem in your code. My theory at this point is it's a bug in that library. I don't have any suggestion for an alternative library. I'll try to see if I can find a bug in the library.

Thanks @Paul and @xfpd. I'll take a look, especially at the power supply, then I'll get back to you.

I can't see a bug in the library. I was hoping there was an error in the timing of the various signals which would account for the ghosting.

Perhaps 1/8th, because the matrix is a combination of the 8x8 modules

There are 4 row select pins, which tells me it is 1:16 multiplexed.

Also

void myMATRIX::Show()
{
    ...
    row++;
    if (row==16) row=0;
}

This function is cycling through 16 rows.

2 Likes

Hi Paul, I don't understand.
Do you mean to add this function to the code? Where?

It's already in the code, the library code.

I was demonstrating to @xfpd and @b707, as well as to you, that the current will be only 1/16th of what it would be if every led was lit simultaneously. They can't all be lit simultaneously, only one row at a time. It may look to the eye that they are all lit together but that isn't true in reality.

1 Like

Ok, don't worry. If by any chance you find any library or code that does the same function as my code, i.e. clock and text scrolling for this matrix, if you want to share it with me, I will be grateful. Even so, I am grateful for trying to help me.

I'm not convinced this is a software problem.

What if you give the library an unused pin as the OE pin, and set the real OE pin to OUTPUT and LOW HIGH in setup()? In theory, the display should be completely blank, but I wonder if you can still see the ghosting.

What is wrong with Post #3? It has library and code.

I thought @Dancopy confirmed that this was the library he is using. But maybe I misunderstood...

I agree.

@Dancopy - Can you photograph the reverse side of your panels, to see the electric characteristics (usually on every piece of electronics) and wiring? Can you break the matrix apart and see if the "faded leds" problem goes away (I suspect the 2A power supply being insufficient)?

I have been trying to understand how the circuits on the display work. The 32x16 matrix appears to contain 4x 74HC138 demultiplexers, 8x 74HC595 shift registers and 8x APM4953 dual p-channel MOSFET chips. Is that correct?

So I guess pairs of 74HC138 are used to make 1-to-16 demultiplexers which drive 16 p-channel MOSFETs to source 5V to the 16 common anodes of a pair of 8x8 bi-colour LED matrices. Groups of 4x 74HC595 shift registers sink current from 32 cathodes of the pair of matrices.

But I don't see a single current limiting resistor! None to limit current through the LEDs or the MOSFET gates. So, unless I'm missing something, this feels like a cheap design that doesn't follow the max current limits of the components used. This may be the reason for the unexpected ghosting, and, if so, there may be no way to fix it.