Home thermometer using a servo

You want the 20 degrees of temperature to play out over the 180 degrees of the servo.

You can use map()

    servoAngle = map(temperature, 10, 30, 0, 180;

and you probably want to use constrain()

   servoAngle = constrain(servoAngle, 0, 180);

because map() will cheerfully extrapolate and give servo angles out of range.

Oh, servopos not servoAngle, sry.

HTH

a7

1 Like