I recently noticed how the map() function in Arduino was bulky in both terms of flash space used and time taken to execute, largely because it deals with long and involves a division and multiplication.
Many times you can replace maps with more basic functions i.e.
output = map(input,0,1023,0,255);
can become
output = input >> 2;
or
output = map(input,0,1023,1023,0);
can become
output = 1023 - input;
I have one line in some code that says:
backlight = map(LDRreading,0,1023,50,250);
How could this be simplified so that it is both space and time efficient?
I'll allow slight differences in output values if it results in a much better solution.
