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 ![]()