part2
const int _Z[] = {B1111111,
B0000010,
B0000100,
B0111110,
B0010000,
B0100000,
B1111111,
B0000000};
const int _COL[] = {B0000000,
B0011000,
B0011000,
B0000000,
B0011000,
B0011000,
B0000000,
B0000000};
const int _DASH[] = {B0000000,
B0000000,
B0000000,
B0111110,
B0000000,
B0000000,
B0000000,
B0000000};
const int _BRA2[] = {B0010000,
B0001000,
B0000100,
B0000100,
B0001000,
B0010000,
B0000000,
B0000000};
const int __[] = {B0000000,
B0000000,
B0000000,
B0000000,
B0000000,
B0000000,
B0000000,
B0000000};
const int _FULL[] = {B00000000,
B00000000,
B00000000,
B00000000,
B00000000,
B00000000,
B00000000,
B00000000};
const int _CHECK[] = {B1010101,
B0101010,
B1010101,
B0101010,
B1010101,
B0101010,
B1010101,
B0000000};
const int _B2[] = {B0111110,
B0000001,
B0000001,
B0001111,
B0000001,
B1000001,
B0111110,
B0000000};
const int _TEMP[] = {B0000011,
B0011111,
B0111111,
B1111110,
B1111111,
B0011111,
B0000011,
B0000000};
const int _LINE[] = {B0000001,
B0000001,
B0000001,
B0000001,
B0000001,
B0000001,
B0000001,
B0000000};
const int _SMILE[] = {B000000,
B1100100,
B1100010,
B0011001,
B1100010,
B1100100,
B0000000,
B0000000};
const int _DOT[] = {B0000000,
B0000000,
B0000000,
B0000000,
B1100000,
B1100000,
B0000000,
B0000000};
const int _COLDOT[] = {B0000000,
B0110000,
B0110000,
B0000000,
B0110011,
B0110011,
B0000000,
B0000000};
const int _num1[] = {B0000010,
B0000110,
B0001010,
B0010010,
B0000010,
B0000010,
B1111111,
B0000000};
const int _num2[] = {B0001100,
B0010010,
B0100100,
B0001000,
B0010010,
B0100000,
B1111111,
B0000000};
const int _num3[] = {B1111000,
B1000100,
B0001000,
B0010000,
B0001000,
B0000100,
B0111000,
B0000000};
const int _num4[] = {B0000010,
B0001110,
B0001010,
B0010010,
B0100010,
B1000010,
B1111111,
B0000010};
const int _num5[] = {B1111100,
B1000000,
B0110000,
B0001000,
B0000100,
B0000100,
B0111000,
B0000000};
const int _num6[] = {B1111111,
B0000001,
B0000001,
B1111111,
B1000001,
B1000001,
B1111111,
B0000000};
const int _num7[] = {B1111111,
B0000010,
B0000100,
B0001000,
B0010000,
B0100000,
B1000000,
B0000000};
const int _num8[] = {B1111111,
B1000001,
B1000001,
B1111111,
B1000001,
B1000001,
B1111111,
B0000000};
const int _num9[] = {B1111111,
B1000001,
B1000001,
B1111111,
B1000000,
B1000000,
B1111111,
B00000000};
const int _num0[] = {B0001100,
B0010010,
B0100001,
B0100001,
B0100001,
B0010010,
B0001100,
B0000000};
//Load the bitmap charachters into an array (each charachters position corresponds to its previously defined index (ie _A (a's bitmap)
//is at index 0 and A = 0 so letters[A] will return the 'A' bitmap)
const int* letters[] = {_A,_B,_C,_D,_E,_F,_G,_H,_I,_J,_K,_L,_M,_N,_O,_P,_Q,_R,_S,_T,_U,_V,_W,_X,_Y,_Z,_COL,_DASH,_BRA2,__, _FULL, _CHECK, _B2, _TEMP, _LINE, _SMILE, _DOT, _COLDOT,_num1,_num2,_num3,_num4,_num5,_num6,_num7,_num8,_num9,_num0};
//Setup runs once when power is applied
void setup()
{ Serial.begin(9600);
for(int i = 0; i <8; i++){ //Set the 16 pins used to control the array as OUTPUTs
pinMode(rowA[i], OUTPUT);
pinMode(colA[i], OUTPUT);
}
}
//repeats
void loop()
{
comdata1();
updateMatrix();
}
void comdata1(){
while (Serial.available() > 0)
{
comdata += char(Serial.read());
delay(2);
}
if (comdata.length() > 0)
{
Serial.println(comdata);
comdata = "";
}
}
void updateMatrix(){
loadSprite();
showSprite(speed);
}
//An array holding the powers of 2 these are used as bit masks when calculating what to display
const int powers[] = {1,2,4,8,16,32,64,128};
//Loads the current scroll state frame into the data[] display array
void loadSprite(){
int currentChar = getChar(comdata[index]);
int nextChar = getChar(comdata[index+1]);
for(int row=0; row < 8; row++){ //iterate through each row
data[row] = 0; //reset the row we're working on
for(int column=0; column < 8; column++){ //iterate through each column
data[row] = data[row] + ((powers[column] & (letters[currentChar][row] << offset))); //loads the current charachter offset by offset pixels
data[row] = data[row] + (powers[column] & (letters[nextChar][row] >> (8-offset) )); //loads the next charachter offset by offset pixels
}
}
offset++; //increment the offset by one row
if(offset==8){offset = 0; index++; if(index==sizeof(comdata)-2){index=0;}} //if offset is 8 load the next charachter pair for the next time through
}
void showSprite(int speed2){
for(int iii = 0; iii < speed2; iii++){ //show the current frame speed2 times
for(int column = 0; column < 8; column++){ //iterate through each column
for(int i = 0; i < 8; i++){
digitalWrite(rowA[i], HIGH); //turn off all row pins
}
for(int i = 0; i < 8; i++){ //Set only the one pin
if(i == column){ digitalWrite(colA[i], HIGH);} //turns the current row on
else{ digitalWrite(colA[i], LOW); }//turns the rest of the rows off
}
for(int row = 0; row < 8; row++){ //iterate through each pixel in the current column
int bit = (data[column] >> row) & 1;
if(bit == 1){
digitalWrite(rowA[row], LOW); //if the bit in the data array is set turn the LED on
}
}
delayMicroseconds(pauseDelay); //leave the column on for pauseDelay microseconds (too high a delay causes flicker)
}
}
}//returns the index of a given charachter
//for converting from a string to a lookup in our array of charachter bitmaps