I am trying to convert RPM's of my car to degrees to work with a nextion UI. However for some reason the 1000-1999 range does not work. When I put the if statement:
if (1000 < RPM <= 2000){ degRPM = (RPM - 1000) * .015 + 348; return(degRPM); }
at the bottom of the function then all the calculations work other than the 1000-1999. If I keep it how it is formatted as below, then all the numbers are wrong... I can't seem to figure out what is causing this.
int calcRPM(int RPM){
int degRPM = 0;
String strRPM = String(RPM);
myNex.writeStr("t0.txt", strRPM);
if (RPM <= 1000){
degRPM = RPM * .015 + 333;
return(degRPM);
}
if (1000 < RPM <= 2000){
degRPM = (RPM - 1000) * .015 + 348;
return(degRPM);
}
if (2000 < RPM <= 3000){
return((RPM - 2000) * .029 + 3);
}
if (3000 < RPM <= 4000){
degRPM = (RPM - 3000) * .028 + 32;
return(degRPM);
}
if (4000 < RPM <= 5000){
degRPM = (RPM - 4000) * .027 + 60;
return(degRPM);
}
if (5000 < RPM <= 6000){
degRPM = (RPM - 5000) * .029 + 87;
return(degRPM);
}
if (6000 < RPM <= 7000){
degRPM = (RPM - 6000) * .029 + 116;
return(degRPM);
}
if (7000 < RPM <= 8000){
degRPM = (RPM - 7000) * .032 + 145;
return(degRPM);
}
if (8000 < RPM <= 9000){
degRPM = (RPM - 8000) * .032 + 177;
return(degRPM);
}
return degRPM;
}