Hello..newbie here
I am trying to scroll led matrix 6x6. Rows are pin 14-19, col are pin2-7 Nano. I am scanning the rows and feeding the column pins with the characters. I have been able to display individual characters and scroll them but when i try scrolling characters different characters like the alphabet, my matrix shows gibberish. Does anyone mind having a look at my code?
Thanks
//Next read from string and pass the values to the matrix
//Improve on the concept of the buffer to scroll fully from full right
//Animations
byte myCharacters[5][8]={{B00000000,
B01111110,
B01000010,
B01111110,
B01000010,
B01000010},//A
{B01111100,
B01100010,
B01111110,
B01111110,
B01100010,
B01111100},//B;
{B00011100,
B01100010,
B01100000,
B01100000,
B01100010,
B00011100},//C;
{B01111100,
B01100110,
B01100111,
B01100111,
B01100111,
B01111100},//D;
{B01111111,
B01100000,
B01111111,
B01111111,
B01100000,
B01100000}};//E;
byte myByte;
byte colByte;
byte bufferB;
byte bufferA=B00000000;
int x;
int colDelay=300;
unsigned long oldTime;
int whichArray=1;
byte arrayIndex;
int timer=1;
int colPin;
int shiftAmount=0;
void setup() {
// put your setup code here, to run once:
for(int pins=0;pins<20;pins++)
{
pinMode(pins,OUTPUT);
}
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.print("\n");
for( int x=0;x<4;x++)
{
for(int rowPin=14;rowPin<20;rowPin++)
{
digitalWrite(rowPin,HIGH);
for(colPin=2;colPin<8;colPin++)
{
int arrayRow=rowPin-14;
int arrayCol=colPin-2;
bufferB=myCharacters[x][arrayRow];
bufferA=(bufferB<<shiftAmount)|(myCharacters[x+1][arrayRow]>>6-shiftAmount);//to scroll different characters modify this code to load current row of next character.
colByte=bufferA;
//Serial.print(bufferA);
//delay(1000);
if (colByte & (B10000000 >> arrayCol)) {//bit mask code helps read the byte into individual bits
digitalWrite(colPin, HIGH);
delayMicroseconds(colDelay); //this determines how bright the leds are
digitalWrite(colPin,LOW);
//Serial.print("1");
//delay(1);
}
else {
digitalWrite(colPin, LOW);
delayMicroseconds(colDelay); //this determines how bright the leds are
// Serial.print("0");
// delay(1);
}
}
//Serial.print("\n");
//Serial.print("new row");
delay(timer);
digitalWrite(rowPin,LOW);
delay(timer);
//for statement for switching character
}
if((millis()-oldTime>1000))//this if statement determines the rate of shift.
{
oldTime=millis();
shiftAmount++;
// Serial.print(shiftAmount);
// Serial.print("\n");
}
if(shiftAmount==6)
{
shiftAmount=0;
}
//Serial.print("new row");
}
//Serial.print("new character");//Serial.print("\n");
}