be aware that the map() function will not guard against out of range values
simple example that show Celsius to Fahrenheit conversion
//
// FILE: mapC2F.pde
// AUTHOR: Rob Tillaart
// DATE: 2012=NOV-04
//
// PUPROSE: showing that map() works outside of ranges provided
//
void setup()
{
Serial.begin(9600);
Serial.println("start...");
}
void loop()
{
for (int i=-100; i<200; i++)
{
Serial.print(i);
Serial.print(":");
Serial.println(map(i,0,100,32,212));
}
while (1);
}
SO: if the getTempC() returns an errorcode say -1000 , the map() function will just do its math, returning => -1768F ![]()
Use constrain() to constrain a value between two values