Here is my code, throttle comes out to -18 when I run the program, and when I do the math I get 77.941... which is what I'm looking for. I know this is an EDQ "Extremely Dumb Question", and I am most likely to experience a FIF, "Fist In Forehead" moment any minute but I am stuck on it for now. FYI, programming it on an Atmega 328P using Arduino IDE on Windows 10.
Following example prints -18 and according to my calcualtions it should be 77.941...
int throttle = (((800 - 270) * 100) / 680);
Serial.println(throttle);
This is the visualized code...
throttle = (((throttleSensor - oldMinValue) * (newMax - newMin)) / (oldMax - oldMin));
I am trying to do this, Convert a number range to another range, maintaining ratio
Also, I should add, it works fine when the result is below 47, above that it flips to a negative number.