Ah map is the thing to look for.
So i also need no calculation.
And constrain that i don't get minus values or more the 100.
void loop() {
valveValue = analogRead(valvePin);
valveInDig = valveValue;
valveRange = map(valveValue, 400, 800, 0, 100);
valvePercentage = constrain(valveRange, 0, 100);
float voltage = valveValue * (5.0 / 1023.0);
// now print it
Serial.print("Dig: "); Serial.print(valveInDig);
Serial.print(", Range: "); Serial.print(valveRange);
Serial.print(", Percentage: "); Serial.print(valvePercentage);
Serial.print(", Volts: "); Serial.println(voltage);
delay(1);
}
But now i start to think about the potentiometer and resolution if i have only a 90° range.
I also want to log the data to SD. But only if there is change that it's not to much data.
So it don't need to be sensitive and that there is not a change just from vibration. I think
logging 5% steps is enough. It's a mechanical valve from the 80s so anyways it's not the
most exact device in the world