Huge data, 2inputs to one output conversion


I have two inputs (numbers), and output(one number) on LCD,

Input one has numbers 0-100,
Input two has numbers 0-380,

The output number is a data I have.

say input one is 50. input two is 300, the corresponding data output is 453.

I was going to use array, but that is going to be like array[100]={}; which didn't work.
And if i use 2d array, there isn't any space.

Can someone please tell me a simpler way to solve the issue?
I was thinking of a mathematical formula, but the output data is not linear.

So you're looking at 101 x 381 x 2 bytes = 76292 bytes of data.
Which Arduino board are you using?

I'm using arduino Mega

I'm using arduino Mega

.. which has 8192 bytes of RAM

.. which has 8192 bytes of RAM

So you must put the table in PROGMEM. The Arduino Meah 2560 has 256kb of PROGMEM so 76kB should not be a problem.
What is the range of output values?
Did the numbers come from some formula that you could use instead of a lookup table?

Is there not an algorithm which defines the output as a function of the 2 inputs?

Bit slower, but far less space consuming.


Range of output values are 0-255. No formula for the numbers, experimental values.

The PROGMEM works, but 101 x 381 is too large, I had to split it into two.

Thank you

No algorithm relates to input output values.

If the output range is 0-255 use 'unsigned char' and your array will only be 38,481 bytes.

I was going off the original post which said:

the corresponding data output is 453.

so that's why I assumed 2 bytes would be necessary for each output item. I guess 453 was a typo?

well, I was trying to show an example.

Thanks for the help :slight_smile: