Home thermometer using a servo

Yes, but you can hand it floats.

I had done, and just now googled

When we pass a float value to a function having int argument, the Implicit typecasting is done here from float to int.


Looks plausible and avoids map(), always a good thing, and uses simple logic instead of constrain().

And... works. There is no roll for servoposraw, it is assigned already conditioned like map() would have done. I used your idea thusly:

  servopos = (180.0 / 20.0) * (temperature - 10.0);

  if (servopos < 0) servopos = 0;
  if (servopos > 180) servopos = 180;

  servo.write(servopos);

map() does make it a little easier to mess with the endpoints and stuff.

a7