I've recently created an LED matrix but now want to create animations for it. I've seen some example sketches but they all use hexadecimal code such as this 0x8f. I was wondering if anyone could give me insight on how to implement hexadecimal code into my matrrix code
thanks in advance:Chris
all letters in the characters array aren't completed i havent created the fonts 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};
//byte scrollActivator[5] = {B00001000, B00011000, B00111000, B01111000, B11111000};
//array that stores letters
byte characters[26][5] = {
{B11111000, B00101000, B00101000, B00101000, B11111000},//0A
{B11111000, B10101000, B10101000, B10101000, B01010000},//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
};
//limited to 160 characters for scroll funtion message unless you change array size
byte scrollArray [160];
int shiftDelayTest;
void setup() {
Serial.begin(9600);
//initializes pins as outputs
for(int A=8; A<=12; A++)
{
pinMode(A, OUTPUT);
}
}
void loop() {
scroll("ABAB");
}
//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) {
//places the message into one long array
//and adds a space after each letter
int Y=0;
int messageLength = message.length();
for(int D=0; D<messageLength; D++)
{
for(int E=0; E<5; E++)
{
scrollArray[(D*5) + Y + E] = characters[(message.charAt(D)) - 'A'][E];
scrollArray[(5*Y) + 5 + Y] = B00000000;
}
Y++;
}
//scrolls out the mesage from the long array
int X=0;
for(int F=0; F<=((messageLength*5) + messageLength); F++)
{
int shiftDelay = 250;
unsigned long timer = millis();
while((timer + shiftDelay) > millis())
{
for(int G=0; G<5; G++)
{
digitalWrite(LP, LOW);
shiftOut(DPC, CPC, LSBFIRST, columnActivator[G]);
shiftOut(DPR, CPR, LSBFIRST, scrollArray[G+X]);
digitalWrite(LP, HIGH);
}
}
X++;
}
}