Creating a lookup table in a microcontroller using in C
I'll give a general answer since the question lacks information: 

Suppose you have an uint8_t as input and a uint8_t as output and you want to create a full lookup table (i.e. every input has an output). You'd need 256 values, as the input can have 256 different values.  You can now create a table with:

const uint8_t the_table[256] = { ... }


The const keyword is to store the table in the flash memory, not in the RAM. This is because RAM is scarce in microcontrollers, as jippie points out in the comments.

In the curly brackets, the values should go. You can now easily lookup an input value with the_table[input_value].



Generally, we could say a lookup table would look as follows: 

const OutputType the_table[CountOfInputValues] = { ... };



A small example for a lookup table to do this conversion (from the Gray code, thanks to Anindo Ghosh):

input -&gt; output
0b000    0b000
0b001    0b001
0b010    0b011
0b011    0b010
0b100    0b110
0b101    0b111
0b110    0b101
0b111    0b100


Might be implemented as follows, using uint8_t, or a byte, as the output type:

const uint8_t gray_code[8] = {0b000, 0b001, 0b011, 0b010, 0b110, 0b111, 0b101, 0b100};


You can lookup a value with:

some_var = gray_code[input];