First of all, a TMP36 sensor is an analog output device. Its output is volts, not bits. The ADC on the Arduino has ten bits, so I don't know where the "9 bit" stuff comes from. I think I can guess where the "20 values" comes from, and I'll show my guess in a minute.
But, first of all:
How many different "fade values" do you really need? Let's say, for the moment, that you would like to have a range of 0 - 255 to make it go from one extreme to the other. Maybe you think you would like more, but, let's say for now that 256 different values are the target. (That's a nice round number.)
Maybe you can experiment with a sketch that doesn't read temperature, but applies different values over some range for certain amounts of time and observe the visual effects of varying the output that many fade steps. I mean, however you get numbers that represent temperature, you have to use the numbers to arrive at values to feed the Arduino pwm output pins that control LED brightness, right? I might start experimenting with the LEDs first and then do the temperature thing after I decided what I really needed to get an acceptable visual result.
Well, let's get to the temperature thing...
Assume for the moment that the TMP36 temperature sensor output voltage is exactly given by its nominal formula:
V = 0.5 + 0.01 * (Temperature in Celsius)
Then for 18C, the output is 0.68 Volts, and for 28 C, the output is 0.78 Volts
Now, assume for the moment that the ADC reference voltage is exactly 5 Volts.
I think that the stated conclusion about "20 values" came from something like working backwards from the Atmel ADC formula to discover the ADC readings from the applied voltage.
A reading of 139 would indicate an applied voltage of approximately 0.688 Volts, which corresponds to 18.8C
A reading of 159 would indicate an applied voltage of approximately 0.776 Volts, which corresponds to 27.6C
Therefore, a temperature swing in the neighborhood of 18C to 28C causes the ADC readings to change only 20 counts.
Now, as Richard said, you can use the internal ADC reference rather than 5 Volts to get a somewhat better spread.
If you assume that the internal bandgap reference voltage is exactly 1.1 Volts and you use that for the ADC reference voltage instead of the default 5 Volts, then
A reading of 633 would indicate an applied voltage of approximately 0.680 Volts, which corresponds to 18.0C
A reading of 726 would indicate an applied voltage of approximately 0.780 Volts, which corresponds to 28.0C
So, now, a temperature swing in the neighborhood of 18C to 28C causes the ADC readings to change 93 counts.
Now, here's a gentle reminder: The bandgap reference voltage might be off by a percent or so, and the ADC readings might be off by a couple of bits, and the temperature sensor reading might be off by a degree or so, so the readings might not be exactly as indicated above.
Now, just between us chickens, I would like offer the opinion that it's just possible that the human eye may not discern a huge subjective difference between having 93 different fade values and having 256 different fade values, so you might want to try scaling the counts so that ADC values from, say, 630 to, say, 730 are mapped to the 0-255 range. If you already have a TMP36 sensor, then maybe you can try something like that. That could be all you need.
If that's not good enough, then...
You could get a better spread with a DS18B20 sensor, which has digital output (using a so-called 1-Wire connection). See Footnote. With this device, a ten-degree Celsius temperature spread gives a count difference (in a 12-bit digital word) of 160 counts. Still not 256, but somewhat better than the analog sensors like the TMP36. More importantly, for some applications, it also doesn't depend on the accuracy of the ATmega analog reference voltage or of any ADC converter bit errors. I have a feeling that for visual effects like you are describing, where absolute accuracy to the nearest tenth of a degree is probably not important, the TMP36 might be just the ticket.
I mean, if there were only one way to do things, then life would be a lot simpler right?
- State the problem.
- Derive or discover (or get someone else to derive or discover) the solution.
- Implement the solution.
Fortunately for the intellectually curious among us, life is more interesting than that.
The DS18B20 has been used successfully in many Arduino designs. It is just as easy to connect as the analog sensors, and 1-Wire Arduino libraries are readily available to read and interpret temperature values. It may be a little more expensive than analog sensors, but a lot of us think it's worth it.