LED Dot Matrix 8x8... Displaying wrong dots

Hi there,
I have been trying to get an 8x8 LED matrix to display an 'A' character without the use of a library. Using two 74HC595 shift registers (one for rows one for columns). It is almost working apart from that three unwanted dots are appearing on the display. I do know why this is happening but I am unsure on how to fix it.

Here is a picture of what should be displayed:

Here is what is being displayed:

(notice the 3 extra pixels turned on in the top left).

I believe this is happening because a row or column can't be set at the same time. Therefore when the active column is changed(only one column and row are 'active' at a time) but the row stays the same, for a split second an unwanted pixel is turned on until the active row is changed.

I am not really sure how to get round this but on youtube videos no-one ever seems to have any problems with libraries so there must be something I am doing wrong...

Here is my code:

int latchCol = 3; //Outputs for the shift registers
int clockCol = 4;
int dataCol = 5;
int latchRow = 8;
int clockRow = 9;
int dataRow = 10;
int pos[]={B11111110,B11111101,B11111011,B11110111,B11101111,B11011111,B10111111,B01111111};

byte chars[] = {B00011000, // An array of the character byte values which is passed into the getDisplayBytes fn.
                B00100100, 
                B01000010,
                B01000010,
                B01111110,
                B01000010,
                B01000010,
                B01000010};
                
int outputRows[64]; // Two arrays to store the 64 possible column and row values. 
int outputColumns[64];
int x=0; // a variable to set the position of an array.
int n = 0; // a variable to set the position of an array.

void setup() {
  pinMode(latchCol,OUTPUT);
  pinMode(clockCol,OUTPUT);
  pinMode(dataCol,OUTPUT);  
  pinMode(latchRow,OUTPUT);  
  pinMode(clockRow,OUTPUT);
  pinMode(dataRow,OUTPUT);

  getDisplayBytes(chars);
  for(int j = 0; j<8; j++)
  {
    for(int i = 0; i<8; i++)
    {
      outputColumns[n] = pos[j]; //set 64 positions to the columns byte array, 8 of B01111111, 8 of B10111111 etc.
      n++;
    }
  }
  
}

void loop() {
    if(outputRows[x]>0)// if the byte is B00000000 then don't display it
    {
      digitalWrite(latchCol,LOW);
      shiftOut(dataCol,clockCol,MSBFIRST,outputColumns[x]);
      digitalWrite(latchCol,HIGH);
      digitalWrite(latchRow,LOW);
      shiftOut(dataRow,clockRow,MSBFIRST,outputRows[x]);
      digitalWrite(latchRow,HIGH);
    }
    x++;  
    if(x>63) //Has been through one cycle of the display, start again, set x to 0;
    {
      x=0;
    }
}

void getDisplayBytes(byte character[]) // A funtion to get seperate bytes to display (because only one '1' can be displayed at a time). 
    int m = 0;                         // Eg B10001000 would get seperated into B10000000 and B00001000 so that there is only one '1' per byte
  {
    for(int j = 0; j<8; j++) //cycle through the outer 'for loop' 8 times to reset Y after setting a row of 8 bytes in the inner 'for loop'
    {
      int y = B10000000;
      for(int i = 0; i<8; i++, y = y >> 1, m++) // increment i, shift Y one bit to the right and increment m.
      {
        outputRows[m] = character[j] & y;
      }
    }
  }

Any help would be much appreciated

Thanks :fearful:

Clear the data being displayed ( shfit out chars data equal to all off) before enabling the next group of data.
You also seem to be blasting thru the data as fast as you can - slow things down with blink without delay, stay on each group of data for a few hundred microseconds before changing.
Even better, replace the common cathode 74HC595 with TPIC6B595 so your multiplexing can have a whole column on at one time with the 6B595 sinking a lot more current than the HC595 can.

Clear the data being displayed ( shfit out chars data equal to all off) before enabling the next group of data.

Thankyou, I didn't think of that but will this not cause the display to be dimmer or appear to flicker?

If you are only turning on 1 LED at a time, perhaps.
If you driving 8 at a time in one column or one row, then you can have a row/column on for 2-3mS each and it will appear nice & bright & flicker free.

OK, I updated the code so that it turns off the display after displaying each pixel and it works perfectly without flickering and it's bright too. Yay :smiley: