Hello Arduino community. I have built a 5X5 LED matrix but have no idea on how to code a scrolling function. The matrix uses two 8 bit shift registers, One for the rows and one for the columns. it is also column scanned. I've been able to write a function to display a singular character and one to display all the characters in a message but just cant get it to scroll. I am not asking for someone to wright the code for me, but merely for guidance on how to approach writing a scroll function
Thanks in advance: Chris
The characters arry only has the letter A font put in, I haven't made the rest of the letters yet
//REV 1.0
//By: Christopher Beharry Yambo with help from the arduino community @www.forum.arduino.cc
/*
* Controls a 5X5 LED matrix consisting of two 8bit shift registers
* It's column scanned meaning that one column comes on at a time from left to right
* Hopefuly I can create scrolling in this first revision
*/
//declaring constant ints for data, clock, and latch pins of the row and column registers
// both registers share the same latch pin
const int CPR = 8;
const int LP = 9;
const int DPR = 10;
const int CPC = 11;
const int DPC = 12;
byte columnActivator[5] = {B10000000, B01000000, B00100000, B00010000, B00001000};
//array that stores letters
byte characters[26][5] = {
{B11111111, B00101000, B00101000, B00101000, B11111000},//0A
{B11111000, B11110000, B11100000, B11000000, B10000000},//1B
{B10000000, B10000000, B10000000, B10000000, B10000000},//2C
{B10000000, B10000000, B10000000, B10000000, B10000000},//3D
{B10000000, B10000000, B10000000, B10000000, B10000000},//4E
{B10000000, B10000000, B10000000, B10000000, B10000000},//5F
{B10000000, B10000000, B10000000, B10000000, B10000000},//6G
{B10000000, B10000000, B10000000, B10000000, B10000000},//7H
{B10000000, B10000000, B10000000, B10000000, B10000000},//8I
{B10000000, B10000000, B10000000, B10000000, B10000000},//9J
{B10000000, B10000000, B10000000, B10000000, B10000000},//10K
{B10000000, B10000000, B10000000, B10000000, B10000000},//11L
{B10000000, B10000000, B10000000, B10000000, B10000000},//12M
{B10000000, B10000000, B10000000, B10000000, B10000000},//13N
{B10000000, B10000000, B10000000, B10000000, B10000000},//14O
{B10000000, B10000000, B10000000, B10000000, B10000000},//15P
{B10000000, B10000000, B10000000, B10000000, B10000000},//16Q
{B10000000, B10000000, B10000000, B10000000, B10000000},//17R
{B10000000, B10000000, B10000000, B10000000, B10000000},//18S
{B10000000, B10000000, B10000000, B10000000, B10000000},//19T
{B10000000, B10000000, B10000000, B10000000, B10000000},//20U
{B10000000, B10000000, B10000000, B10000000, B10000000},//21V
{B10000000, B10000000, B10000000, B10000000, B10000000},//22W
{B10000000, B10000000, B10000000, B10000000, B10000000},//23X
{B10000000, B10000000, B10000000, B10000000, B10000000},//24Y
{B10000000, B10000000, B10000000, B10000000, B10000000},//25Z
};
void setup() {
Serial.begin(9600);
//initializes pins as outputs
for(int A=8; A<=12; A++)
{
pinMode(A, OUTPUT);
}
}
void loop() {
show("A B");
}
//function to show a singular character from the letter array
void showCharacter(int outputCharacter) {
int letter = (outputCharacter - 65);
for(int B=0; B<5; B++)
{
digitalWrite(LP, LOW);
shiftOut(DPC, CPC, LSBFIRST, columnActivator[B]);
shiftOut(DPR, CPR, LSBFIRST, characters[letter][B]);
digitalWrite(LP, HIGH);
}
}
//function to show a message with a delay between each character
void show(String message) {
int characterDelay = 650;
for(int C=0; C<message.length(); C++)
{
int character = message.charAt(C);
unsigned long timer = millis();
while((characterDelay + timer) > millis())
{
//if theres a space in the message all 0's are shifted out
if(character == 32)
{
digitalWrite(LP, LOW);
shiftOut(DPC, CPC, LSBFIRST, B00000000);
shiftOut(DPR, CPR, LSBFIRST, B00000000);
digitalWrite(LP, HIGH);
}
//otherwise the correct letter is shifted out
else
{
showCharacter(character);
}
}
}
}
//function to scroll a message
void scroll(String message) {
}