Arduino Ambient Temperature Monitor
The circuit is basically a voltage divider to measure the resistance of the thermistor, a bit of maths to convert a measurement of ohms into degrees C and then some more simple maths to work out what colour to make the LED and finally using the three PWM pins on the Arduino make the LED fade as necessary.
Part List
1x 100k ohm resistor
1x 100k thermistor
1x RGB LED - I've got common anode but common cathode would work just as well
1x Arduino
The Schematic
Step One - Whats The Resistance
Before we can do anything with LEDs we need to get the current resistance of the thermistor, this is achieved by use of a simple voltage divider, I found the code needed on a forum.
Placing the 100k fixed resitor between the 5v output and analoge pin 0, and the thermistor between pin 0 and ground creates a voltage divider which can be probed by a simple analogRead(0).
Step Two - Whats The Temperature
Now we've got the value of the thermistors current resistance in ohms, we do some magical maths to get a value in degrees.
I did some homework before writing the code; the Maplins cataloge for the thermistor I'm using indicatesthe following;
| at 25 C: | 100kΩ |
| at 100 C: | 4.77kΩ |
| at 0 C: | 352.4kΩ |
So, I put the values into OpenOffice Calc, made a simple graph with the three points, but then using the "Draw Trend Line" function, create a curve of best fit based on a natural log (ln) and got hold of the equation for the curve.
Armed with a mathematical function that'll tell me the resistance at various temperatures, a bit of algebra means we can tell the temperature at difference resistances. Huzzah. (Note that negative temperatures go a bit wonky so its a bit useless there...)
Without going into too much detail, the getTemp() function has all of step 1 and step 2 in one go.
Step Three - Ambience
So we know the temperature in degrees, lets show it off... the showTemp( float temp ) function does the heavy lifting of calculating what colour should be used to show the current temperature by comparing against some fixed points.
If its colder than 10 degrees then show Blue, at 20 show Green, and above 30 its Red. Between those values it calculates a difference between the colours so we get a nice gentle fade.
The Code

