Is there a way to map a constant changing value (0-200) to be 0 at 0, and 255 when it reaches 100, and back down to 0 when it reaches 200? I can't figure out a way to code this. Would love to hear from you if you have any ideas how to fix this problem I have.
What I have now is: brightness map(val, 0, 100, 0, 255);
This works but only up to 100, when I exceed 100, it goes immediately down to 0 but has to be going back in reverse (255 to 0).
If the input value is always in the range 0..200 then you could map that value to the range 0..510. After that you test if the value is above 255 and if so you do something like: value = 255 - (value - 255).