# Indexing of a table or lookup table

I was trying to figure how to do a table that could be called like print (A) See I want to send the binary value to make a A show up on a 8x8 led display which sending 01000001 is not what it takes to scan the leds. So I was thinking of how to index the letters and numbers to point to the table data scaned. That way I could make a print engine so to say that would print like print("my words") that sends each letter to be displayed in order to see them on a some 8x8s

Thanks burt

Look at the ASCII code for the letters that you want to print. 'A' = 65, 'B' = 66, 'C' = 67 etc, etc

So, you could use theLetter - 65 as the index to an array of values for each letter.

In simple terms you need 8 bytes to hold the pattern for the 8 rows of LEDs for every letter. It's rather tedious to make the patterns, but you only need to do it once. You might even be able to find them online.

When you have the 8 bytes for one letter - something like 00010000 00101000 01000100 01111100 10000010

(I know there aren't 8 rows, I'm lazy) and you need to figure out some code for a function to make the relevant LEDs light to show the letter.

Then you can create an array of these 8-byte patterns which you can use to display the letters. Suppose A was 1 and B was 2 etc then you could call your function like displayBits(1). And you could perhaps arrange your function to "translate" 'A' into 1 so you could call it with displayBits('A').

The idea is fairly simple - but there will be a bit of effort to implement it.

...R

When I was posting this I thought of the acii Dec value but most compliers want index to start at 0 and up and then I figured pointers for each guess pointers from 0 to 9 and A to Z and a to z would work but I want to make this work like sending acii text using just print () holding the text or number and the engine doing the rest

Robin2 I see 3 or so ways to do this but I'm trying to figure one that I could use print as the computer does to and it call the engine ill Have to find they part that handes text stdo

I want to index the big letter ABC

``````int letterA[] ={B00110000,B01001000,B10000100,B10000100,B11111100,B10000100,B10000100,B10000100}
int letterB[] ={B11111000,B10000100,B10000100,B11111000,B11111000,B10000100,B10000100,B11111000}
int letterC[] ={B00111000,B01000100,B10000000,B10000000,B10000000,B10000000,B01000100,B00111000}
int letterD[] ={B11110000,B10001000,B10000100,B10000100,B10000100,B10000100,B10001000,B11110000}
int letterE[] ={B11111100,B10000000,B10000000,B11100000,B11100000,B10000000,B10000000,B11111100}
int letterF[] ={B11111100,B10000000,B10000000,B11110000,B11110000,B10000000,B10000000,B10000000}
int letterG[] ={B00111000,B01000100,B10000100,B10000000,B10011000,B10000100,B01000100,B00111000}
int letterH[] ={B10000100,B10000100,B10000100,B10000100,B11111100,B10000100,B10000100,B10000100}
int letterI[] ={B11111110,B00010000,B00010000,B00010000,B00010000,B00010000,B00010000,B11111110}
int letterJ[] ={B11111110,B00010000,B00010000,B00010000,B00010000,B10010000,B10010000,B01100000}
int letterK[] ={B10000100,B10001000,B10010000,B11100000,B11100000,B10010000,B10001000,B10000100}
int letterL[] ={B10000000,B10000000,B10000000,B10000000,B10000000,B10000000,B10000000,B11111100}
int letterM[] ={B10000010,B11000110,B10101010,B10010010,B10000010,B10000010,B10000010,B10000010}
int letterN[] ={B10000010,B11000010,B11100010,B10110010,B10011010,B10001110,B10000110,B10000010}
int letterO[] ={B00110000,B01001000,B10000100,B10000100,B10000100,B10000100,B01001000,B00110000}
int letterP[] ={B11110000,B10001000,B10000100,B10001000,B11110000,B10000000,B10000000,B10000000}
int letterQ[] ={B00110000,B01001000,B10000100,B10000100,B10000100,B10000100,B01001000,B00110100}
int letterR[] ={B11110000,B10001000,B10000100,B10001000,B11110000,B10001000,B10000100,B10000100}
int letterS[] ={B01110000,B10001000,B00001000,B00110000,B01000000,B10000000,B10001000,B01110000}
int letterT[] ={B11111110,B00010000,B00010000,B00010000,B00010000,B00010000,B00010000,B00010000}
int letterU[] ={B10000100,B10000100,B10000100,B10000100,B10000100,B10000100,B01001000,B00110000}
int letterV[] ={B10000100,B10000100,B10000100,B10000100,B10000100,B10000100,B01001000,B00110000}
int letterW[] ={B10000010,B10000010,B10000010,B10000010,B10000010,B10010010,B01010100,B00101000}
int letterX[] ={B10000010,B01000100,B00101000,B00010000,B00010000,B00101000,B01000100,B10000010}
int letterY[] ={B10000010,B01000100,B00101000,B00010000,B00010000,B00010000,B00010000,B00010000}
int letterZ[] ={B11111100,B00000100,B00001000,B00010000,B00010000,B00100000,B01000000,B11111100}
``````

So i how do you do a

``````letterA = 'A'
``````
``````int* letters[] = {letterA, letterB, letterC, ... etc. etc.};

int getIndexFromAscii(char aChar){
return aChar - 'A';
}
``````

So, "A" is a value of 65 decimal. (you should get into the habit of using hex as soon as possible). The letters count up sequentially to "Z" which is 90 decimal. You can therefore receive an ascii character and subtract 65 from any value. This will normalize you letters to 0-25. You now have your character index. But your character array contains 8 bytes for every character. So to find the index for the array multiply the character index by 8 and that's your array index.

Note that it's easy to expand back to include digits & punctuation or forward to include the lower case letters. As long as your character array is in order and each character requires 8 bits of storage, this scheme will work. You also need to validate the value for the character received someplace in the code.

So the letter 'A' is: ("A" - 65) * 8 = 0. And '0' is the index to your array for the letter "A"..

I think it would take a little more then that to do a this I need to index the name and the values in each

Like print DOG would send

``````int letterD[] ={B11110000,B10001000,B10000100,B10000100,B10000100,B10000100,B10001000,B11110000}
int letterO[] ={B00110000,B01001000,B10000100,B10000100,B10000100,B10000100,B01001000,B00110000}
int letterG[] ={B00111000,B01000100,B10000100,B10000000,B10011000,B10000100,B01000100,B00111000}
``````

Can arduino do multidimensional arrays?

I need to index the letters and numbers pointing to the 8 bytes it takes to load a 8x8 led array.

Try something like

``````byte dataTable[][8] = { {1,2,3,4,5,6,7,8 }, {11,12,13,14,15,16,17,18 }, };
...
oneByte = dataTable[charSelect][byteSelect];
``````

You get rid of all the individual arrays and put all bytes in a single "characters" array. You know where every "letter" is: it's 8 bytes from the previous letter or (n - 1) * 8.

be80be: Can arduino do multidimensional arrays?

Arduino can do any C code that fits on the memory constrained hardware. Have you looked at this example: http://playground.arduino.cc/Code/PCD8544 Their array is set up for a 5x8 matrix, but the idea is the same.

There 26 letter in the alphabet it for now it will be 52 plus 0 to 9 I think the easy way to get the row data is as I posted in post 5 not because it's less typing then hex but because I can see how it looks on the leds when I stack up the 8 rolls.

Now if I did a 62 array like

``````indexTable [62] = {letterA, letterB, ,,,,,,,,,,,,,,,,,,,, number0, number1,,,};
``````

would this work to get the letters and numbers I want ?

Get an ascii table. The numbers come before the letters. For the array indexing to work, you have to have everything in the order of the ascii table and no omissions. You can start anywhere, just adjust the value you subtract with.

You can have two or more tables if you want only numbers and alpha for example and don't want to type in all the punctuation. Since you need to validate your input character anyway, you can decide which table to use by testing the input character.

I was playing with this but I have something wrong

``````int indexTable[][8] =
{
{B00110000,B01001000,B10000100,B10000100,B11111100,B10000100,B10000100,B10000100} //A
,{B11111000,B10000100,B10000100,B11111000,B11111000,B10000100,B10000100,B11111000} //B
,{B00111000,B01000100,B10000000,B10000000,B10000000,B10000000,B01000100,B00111000} //C
,{B11110000,B10001000,B10000100,B10000100,B10000100,B10000100,B10001000,B11110000} //D
,{B11111100,B10000000,B10000000,B11100000,B11100000,B10000000,B10000000,B11111100} //E
,{B11111100,B10000000,B10000000,B11110000,B11110000,B10000000,B10000000,B10000000} //F
,{B00111000,B01000100,B10000100,B10000000,B10011000,B10000100,B01000100,B00111000} //G
,{B10000100,B10000100,B10000100,B10000100,B11111100,B10000100,B10000100,B10000100} //H
,{B11111110,B00010000,B00010000,B00010000,B00010000,B00010000,B00010000,B11111110} //I
,{B11111110,B00010000,B00010000,B00010000,B00010000,B10010000,B10010000,B01100000} //J
,{B10000100,B10001000,B10010000,B11100000,B11100000,B10010000,B10001000,B10000100} //K
,{B10000000,B10000000,B10000000,B10000000,B10000000,B10000000,B10000000,B11111100} //L
,{B10000010,B11000110,B10101010,B10010010,B10000010,B10000010,B10000010,B10000010} //M
,{B10000010,B11000010,B11100010,B10110010,B10011010,B10001110,B10000110,B10000010} //N
,{B00110000,B01001000,B10000100,B10000100,B10000100,B10000100,B01001000,B00110000} //O
,{B11110000,B10001000,B10000100,B10001000,B11110000,B10000000,B10000000,B10000000} //P
,{B00110000,B01001000,B10000100,B10000100,B10000100,B10000100,B01001000,B00110100} //Q
,{B11110000,B10001000,B10000100,B10001000,B11110000,B10001000,B10000100,B10000100} //R
,{B01110000,B10001000,B00001000,B00110000,B01000000,B10000000,B10001000,B01110000} //S
,{B11111110,B00010000,B00010000,B00010000,B00010000,B00010000,B00010000,B00010000} //T
,{B10000100,B10000100,B10000100,B10000100,B10000100,B10000100,B01001000,B00110000} //U
,{B10000100,B10000100,B10000100,B10000100,B10000100,B10000100,B01001000,B00110000} //V
,{B10000010,B10000010,B10000010,B10000010,B10000010,B10010010,B01010100,B00101000} //w
,{B10000010,B01000100,B00101000,B00010000,B00010000,B00101000,B01000100,B10000010} //X
,{B10000010,B01000100,B00101000,B00010000,B00010000,B00010000,B00010000,B00010000} //Y
,{B11111100,B00000100,B00001000,B00010000,B00010000,B00100000,B01000000,B11111100} //Z
};
void setup() {

Serial.begin(9600); // opens serial port, sets data rate to 9600 bps

} //close setup()

void loop() {

//this nested for loop will turn each LED on and off in sequence

for(int i = 0; i < 8; i++){

for(int j = 0; j < 26; j++){

delay(500);
Serial.println(indexTable[i]);
Serial.println(indexTable[][j]);
Serial.println("");

}//close for i

}//close for j

} //close loop()
``````

Why is this an int? int indexTable[][8] = Whole array is filled with bytes.

Are all the entries printable characters? If not, you may not see anything in the serial monitor.

There are no lines controlling IO pins, how are LEDs to be turned on? You don't seem to have any IO multiplexing going on.

Just a one dimensional byte array. One set of { }. One set of [ ]. 8 bytes per line and comments will help the human read the array.