Saturday, May 15, 2010

[DIY] arduino and temperature sensor LM35

I accidentalmy hand 2weeks ago when I left my solder iron on for a prolonged period and I grabbed the metal guard. It is really a painful mistake. Luckily, no 3rd degree burn of that sort.

So prevent this from happening again, I decided to make a colour changing bling that reacts to temperature. All I is just hook up the temperature sensor to the heat source, for this example, the metal guard. It can be also modified to be fitted into a tap to give visual warning on the temperature of the water.

I laid my paws on RGB LEDs from sim lim tower that cost $1 per piece. It is on the pricey side and i only bought 5 of them. Loaned 1 to nigel and saravanan each for their D&I. Mr.Chew told me last Wednesday he got some for 40cents each (at 100pc lar)!! I felt I was really ripped off....I also have a temperature sensor LM35z lying in some dark corner in my tool box..

To light up R,G and B individually, just connect it to a logic low. My RGB LED is the common anode type. In arduino, this can be achieve by using the digital write.

But, to achieve "blending" of another color, it is necessary to input different intensity of Red, Green and Blue for that "new" colour. Hence an analog write is used.
I have used a 0-255 value, it is the same as programming HTML colour blending.

connect as below
int redLED=11; //Pin11 = Red LED
int blueLED=10; //Pin10 = Blue LED
int greenLED=9; //Pin9 = Green LED
A0 connect to vout of LM35z.

Vout is scaled to 1024 steps for easy conversion.

the code below is for your reference. Uncomment the colour blending part to play with the RGB LED.

take a look at the video. My office is at 20degC -> BLUE, my laptop is emitting heat at 30degC +++ RED. Anything in between, green.

No comments: