LM35 LED Temperature Bar
Intro: LM35 LED Temperature Bar
This is my first instructable, I have watched the website for a few years now and have recently done one of my first, worthy of record, project. Using an LM35 precision temperature sensor,I then display the temperature on a scale of 8 LEDS. The downside to this current set up is that you can only view 8 degrees of temperature.
Requirements:
Arduino, I used an uno
Breadboard
LEDs
Jumpers, M-M
Resistors for LED
LM35
Computer
Arduino IDE.
Notes:
In the code you can change the temperature triggers for the LEDs, to better suit your situation.
Requirements:
Arduino, I used an uno
Breadboard
LEDs
Jumpers, M-M
Resistors for LED
LM35
Computer
Arduino IDE.
Notes:
In the code you can change the temperature triggers for the LEDs, to better suit your situation.
STEP 1: Breadboard Setup LEDs
I will upload a circuit diagram/fritzing when I have the time.
It is a very basic setup, don't be confused by my excessive use of wires.
To begin with locate 8 LEDs of your own preferred colours and put them into your breadboard, positive leg into the main tracks, negative into the ground rail.
Next put your resistors from the track opposite your led, over the middle and into the same track as each individual LED.
Now plug jumpers Into the same tracks as your resistors, 8 in total and connect them to pins 2,3,4,5,7,8,9,10 on your arduino.
Finally link the ground rail of your breadboard to ground on your arduino.
It is a very basic setup, don't be confused by my excessive use of wires.
To begin with locate 8 LEDs of your own preferred colours and put them into your breadboard, positive leg into the main tracks, negative into the ground rail.
Next put your resistors from the track opposite your led, over the middle and into the same track as each individual LED.
Now plug jumpers Into the same tracks as your resistors, 8 in total and connect them to pins 2,3,4,5,7,8,9,10 on your arduino.
Finally link the ground rail of your breadboard to ground on your arduino.
STEP 2: Breadboard Setup Sensor
I decided to use an LM35 simply because it worked for me but other sensor in a similar package should work.
Ben the sensors legs into 3 lanes on the breadboard, use the image above to wire out 5v to arduino 5v, analogue voltage out to arduino A0 and Ground to the ground rail on the breadboard.
Your breadboard should now be setup.
Ben the sensors legs into 3 lanes on the breadboard, use the image above to wire out 5v to arduino 5v, analogue voltage out to arduino A0 and Ground to the ground rail on the breadboard.
Your breadboard should now be setup.
STEP 3: The Code
The code itself is very beginner code as I am still working on a way to condense it using the array functionality.
Apologies, i thought the code was in already on text form.
float temp;
int tempPin = 0;
int pin2 = 2;
int pin3 = 3;
int pin4 = 4;
int pin5 = 5;
int pin7 = 7;
int pin8 = 8;
int pin9 = 9;
int pin10 = 10;
void setup()
{
pinMode(pin2, OUTPUT);
pinMode(pin3, OUTPUT);
pinMode(pin4, OUTPUT);
pinMode(pin5, OUTPUT);
pinMode(pin7, OUTPUT);
pinMode(pin8, OUTPUT);
pinMode(pin9, OUTPUT);
pinMode(pin10, OUTPUT);
Serial.begin(9600);
}
void loop()
{
temp = analogRead(tempPin);
temp = (5.0 * temp * 100.0)/1024.0;
Serial.print(temp);
Serial.println();
if(temp>=16.00){digitalWrite(pin10,HIGH);}
if(temp>=17.00){digitalWrite(pin9,HIGH);}
if(temp>=18.00){digitalWrite(pin8,HIGH);}
if(temp>=19.00){digitalWrite(pin7,HIGH);}
if(temp>=20.00){digitalWrite(pin5,HIGH);}
if(temp>=21.00){digitalWrite(pin4,HIGH);}
if(temp>=22.00){digitalWrite(pin3,HIGH);}
if(temp>=23.00){digitalWrite(pin2,HIGH);}
delay(99);
digitalWrite(pin10,LOW);
digitalWrite(pin9,LOW);
digitalWrite(pin8,LOW);
digitalWrite(pin7,LOW);
digitalWrite(pin5,LOW);
digitalWrite(pin4,LOW);
digitalWrite(pin3,LOW);
digitalWrite(pin2,LOW);
delay(1);
}
Apologies, i thought the code was in already on text form.
float temp;
int tempPin = 0;
int pin2 = 2;
int pin3 = 3;
int pin4 = 4;
int pin5 = 5;
int pin7 = 7;
int pin8 = 8;
int pin9 = 9;
int pin10 = 10;
void setup()
{
pinMode(pin2, OUTPUT);
pinMode(pin3, OUTPUT);
pinMode(pin4, OUTPUT);
pinMode(pin5, OUTPUT);
pinMode(pin7, OUTPUT);
pinMode(pin8, OUTPUT);
pinMode(pin9, OUTPUT);
pinMode(pin10, OUTPUT);
Serial.begin(9600);
}
void loop()
{
temp = analogRead(tempPin);
temp = (5.0 * temp * 100.0)/1024.0;
Serial.print(temp);
Serial.println();
if(temp>=16.00){digitalWrite(pin10,HIGH);}
if(temp>=17.00){digitalWrite(pin9,HIGH);}
if(temp>=18.00){digitalWrite(pin8,HIGH);}
if(temp>=19.00){digitalWrite(pin7,HIGH);}
if(temp>=20.00){digitalWrite(pin5,HIGH);}
if(temp>=21.00){digitalWrite(pin4,HIGH);}
if(temp>=22.00){digitalWrite(pin3,HIGH);}
if(temp>=23.00){digitalWrite(pin2,HIGH);}
delay(99);
digitalWrite(pin10,LOW);
digitalWrite(pin9,LOW);
digitalWrite(pin8,LOW);
digitalWrite(pin7,LOW);
digitalWrite(pin5,LOW);
digitalWrite(pin4,LOW);
digitalWrite(pin3,LOW);
digitalWrite(pin2,LOW);
delay(1);
}
STEP 4: Done
Please give me feedback and opinions.
12 Comments
xanderdk 10 years ago
Nice instructable, just use screen shots instead off cam pictures. And people using the TMP36 sensor be aware that you need to do some changes in the "temp" part of the code otherwise you will get wrong readings and your led's will be on all the time.
AlistairM 10 years ago
xanderdk 10 years ago
Oh okay cool, haven't seen your others yet but i will follow your work. Keep up the good work.
AlistairM 10 years ago
thematthatter 10 years ago
I don't know if there is something different between the TMP36 vs LM35. But I tweaked it a bit and it works now. The Serial is outputting 22.27C which is more realistic.
float temp;
int tempPin = 0;
int pin2 = 2;
int pin3 = 3;
int pin4 = 4;
int pin5 = 5;
int pin7 = 7;
int pin8 = 8;
int pin9 = 9;
int pin10 =10;
void setup()
{
pinMode(pin2, OUTPUT);
pinMode(pin3, OUTPUT);
pinMode(pin4, OUTPUT);
pinMode(pin5, OUTPUT);
pinMode(pin7, OUTPUT);
pinMode(pin8, OUTPUT);
pinMode(pin9, OUTPUT);
pinMode(pin10, OUTPUT);
Serial.begin(9600);
}
void loop()
{
temp = analogRead(tempPin)*.004882814;
temp =(temp - .5) * 100;
Serial.print("TEMPERATURE = ");
Serial.print(temp);
Serial.print("*C");
Serial.println();
if(temp>=18){digitalWrite(pin10,HIGH);}
if(temp>=19){digitalWrite(pin9,HIGH);}
if(temp>=20){digitalWrite(pin8,HIGH);}
if(temp>=21){digitalWrite(pin7,HIGH);}
if(temp>=22){digitalWrite(pin5,HIGH);}
if(temp>=23){digitalWrite(pin4,HIGH);}
if(temp>=24){digitalWrite(pin3,HIGH);}
if(temp>=25){digitalWrite(pin2,HIGH);}
delay(99);
digitalWrite(pin10, LOW);
digitalWrite(pin9, LOW);
digitalWrite(pin8, LOW);
digitalWrite(pin7, LOW);
digitalWrite(pin5, LOW);
digitalWrite(pin4, LOW);
digitalWrite(pin3, LOW);
digitalWrite(pin2, LOW);
delay(1);
}
KDLaun 10 years ago
I suppose I really should post it here on Instructables, someone might get an idea or two or tell me how I can improve on it.
AlistairM 10 years ago
AlistairM 10 years ago
thematthatter 10 years ago
can you just copy paste the code?
thematthatter 10 years ago
You should paste the code as text in the instructable.
Im using a tmp 36, my serial output says its 72C. Any idea what im doing wrong?
AlistairM 10 years ago
thematthatter 10 years ago
One suggestion, use screen captures instead of taking a picture of your computer monitor. Its cleaner, better quality and its easier. (mash CTRL and PRT SC) then you can paste in your favorite image editing program.