In Trial 3: The analog readings that range from 200 to 800 are mapped to a range of 0 to 100. Therefore if the analog readings drop below 200, we will end up with a negative value for sensorVal.
If the analog readings go above 800, we will end up with a value greater than 100. For this particular example, my readings actually range from -33 to 137.
Therefore an Analog reading of 0 = -33
Analog reading of 200 = 0
Analog reading of 800 = 100
Analog reading of 1023 = 137
My questions are how does this guy get -33 and +137?
did you look at the graph? The red line is what you are mapping. (I know it's not to scale and doesnt line up perfectly, that's what you get for 90 seconds in paint though...)
Analog input on the arduino range from 0 to 1023.
If you map something from 200 to 800 that doesn't change that there are still 1024 total steps available from the input.
If your map function makes 200 == 0 then would it not make some sense that <200 == <0? The inverse would also be true of 100 and 800...
What a concept!, Actually checking something prior to posting a question.
I shall try to remember this prior to posting a dumb question that I might solve by removing my shoes and socks to unleash my calculator or have someone else think for me...