I am attempting to assign a percentage value to a raw analog input that is nonlinear over its range.
But I am thinking there may not be a straightforward solution.
When the sensor is at the bottom end of its scale it reads 190 and at the top end 575
for a total count range of 385.
The sensor detects changes in water level on a 10 trace grid; each grid is 1 1/2" in length. When it barely contacts water at the bottom of the grid it starts reading around 180-190 counts.
Water 1st Detected: 180-190 [0.0"]
1/4 range : 450
1/2 : 515
3/4 : 550
Full range: 575 [1.5"]
I would like to convert the counts to a percentage value to represent how full the container is. But because the output is nonlinear I cannot simply assign X counts = X percent.
I looked at the map() function but I do not think it compensates for nonlinearity.
Otherwise I am left to try and create some sort of table that references a specific percentage (%) value based on the input count value.
I was trying to avoid the if statement route and use as a last resort.
Is there any good links that would cover populating a table and then open the table and find a search result?
What is required to run the map() function? I figured it was in the standard library
with all the other functions.
C:\Users\Ed\AppData\Local\Temp\.arduinoIDE-unsaved2024431-4120-rhlqsi.fxby\sketch_may31b\sketch_may31b.ino:2:10: fatal error: map: No such file or directory
// put your setup code here, to run once:
^~~~~
compilation terminated.
exit status 1
Compilation error: map: No such file or directory