Hi All!
I have an 8x8 LED Matrix but I have no idea how to construct code to make it scroll. Below is the code I have to simply display a letter, but thats all I can figure out at this point. I'll also attach the schematic. Any help or guidance would be appreciated!
const int rClock = 2; //chip pin 7
const int rData = 0; //chip pin 5
const int cData = 4; //chip pin 3
const int latch = 1; //chip pin 6
const int cClock = 3; //chip pin 2
//byte rowActivator[] = {B10000000, B01000000, B00100000, B00010000, B00001000, B00000100, B00000010, B00000001};
byte rowActivator[] = {B00000001, B00000010, B00000100, B00001000, B00010000, B00100000, B01000000, B10000000};
byte letters[27][8] =
{
{B00000000, B00111000, B01000100, B01000100, B01000100, B01111100, B01000100, B01000100}, //A0
{B00000000, B01111000, B01000100, B01000100, B01111000, B01000100, B01000100, B01111000}, //B1
{B00000000, B00111000, B01000100, B01000000, B01000000, B01000000, B01000100, B00111000}, //C2
{B00000000, B01110000, B01001000, B01000100, B01000100, B01000100, B01001000, B01110000}, //D3
{B00000000, B01111100, B01000000, B01000000, B01111100, B01000000, B01000000, B01111100}, //E4
{B00000000, B01111100, B01000000, B01000000, B01111000, B01000000, B01000000, B01000000}, //F5
{B00000000, B01111000, B01000100, B01000000, B01011100, B01000100, B01000100, B00111100}, //G6
{B00000000, B01000100, B01000100, B01000100, B01111100, B01000100, B01000100, B01000100}, //H7
{B00000000, B01110000, B00100000, B00100000, B00100000, B00100000, B00100000, B01110000}, //I8
{B00000000, B00011100, B00001000, B00001000, B00001000, B00001000, B01001000, B00110000}, //J9
{B00000000, B01000100, B01001000, B01010000, B01100000, B01010000, B01001000, B01000100}, //K10
{B00000000, B01000000, B01000000, B01000000, B01000000, B01000000, B01000000, B01111100}, //L11
{B00000000, B01000100, B01101100, B01010100, B01010100, B01000100, B01000100, B01000100}, //M12
{B00000000, B01000100, B01000100, B01100100, B01010100, B01001100, B01000100, B01000100}, //N13
{B00000000, B00111000, B01000100, B01000100, B01000100, B01000100, B01000100, B00111000}, //O14
{B00000000, B01111000, B01000100, B01000100, B01111000, B01000000, B01000000, B01000000}, //P15
{B00000000, B00111000, B01000100, B01000100, B01000100, B01010100, B01001000, B00110100}, //Q16
{B00000000, B01111000, B01000100, B01000100, B01111000, B01010000, B01001000, B01000100}, //R17
{B00000000, B00111100, B01000000, B01000000, B00111000, B00000100, B00000100, B01111000}, //S18
{B00000000, B01111100, B00010000, B00010000, B00010000, B00010000, B00010000, B00010000}, //T19
{B00000000, B01000100, B01000100, B01000100, B01000100, B01000100, B01000100, B00111000}, //U20
{B00000000, B01000100, B01000100, B01000100, B01000100, B01000100, B00101000, B00010000}, //V21
{B00000000, B01000100, B01000100, B01000100, B01010100, B01010100, B01010100, B00101000}, //W22
{B00000000, B01000100, B01000100, B00101000, B00010000, B00101000, B01000100, B01000100}, //X23
{B00000000, B01000100, B01000100, B01000100, B00101000, B00010000, B00010000, B00010000}, //Y24
{B00000000, B01111100, B00000100, B00001000, B00010000, B00100000, B01000000, B01111100}, //Z25
{B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000}, // Space to shift 32
};
void setup() {
//Serial.begin(9600); Isn't supported on the ATtiny85
pinMode(rClock, OUTPUT);
pinMode(rData, OUTPUT);
pinMode(cData, OUTPUT);
pinMode(latch, OUTPUT);
pinMode(cClock, OUTPUT);
}
void loop() {
displayLetter('A');
}
void displayLetter(char letter)
{
for(int i=0; i<8; i++)
{
clrData();
digitalWrite(latch, LOW);
shiftOut(rData, rClock, LSBFIRST, rowActivator[i]); // change to just 'i' to fip image
shiftOut(cData, cClock, LSBFIRST, letters[letter - 65][i]);
digitalWrite(latch, HIGH);
delay(1);
}
}
//function yo clear the row registers preventing "ghosting"
void clrData()
{
digitalWrite(latch, LOW);
shiftOut(rData, rClock, LSBFIRST, B00000000);
digitalWrite(latch, HIGH);
}