Any formula/library/code for Temperature to LED color

Has anyone developed any algorithm for generating RGB based on temperature:

  • Blue = Cold (say… 24 deg)

    Green = maybe 30 deg?

    Yellow = 40 deg

    Orange = 50 deg

    Red = Hot 65+ deg



  • And shades in between?

    Someone has to have developed a nice formula.

    DIY

    Hi. You posted the same question on Arduino forum and got a couple of replies, including one from me:

      int temp;
      byte red, green, blue;
    
      temp = constrain(temp, 24, 65);
      if (temp > 30) {
        red = map(temp, 30, 65, 0, 255);
        green = 255 - red;
        blue = 0;
      }
      else {
        red = 0;
        green = map(temp, 24, 30, 0, 255);
        blue = 255 - green;
      }
    

    Paul