I have arduino uno r3, temp sensor lm335z and 2 led. I found this code in internet
float celsius = 0, kelvin=0;
void setup()
{
Serial.begin(9600);
}
void loop()
{
kelvin = analogRead(0) * 0.004882812 * 100;
celsius = kelvin - 273.15;
Serial.print("Celsius: ");
Serial.println(celsius);
//Serial.print("Kelvin: ");
//Serial.println(kelvin);
Serial.println();
delay(10000);
}
and works great with this schema
I add two led with this code:
float celsius = 0, kelvin=0;
int led_green = 13;
int led_red = 12;
void setup()
{
Serial.begin(9600);
pinMode(led_green, OUTPUT);
pinMode(led_red, OUTPUT);
}
void loop()
{
kelvin = analogRead(0) * 0.004882812 * 100;
celsius = kelvin - 273.15;
Serial.print("Celsius: ");
Serial.println(celsius);
//Serial.print("Kelvin: ");
//Serial.println(kelvin);
Serial.println();
if (celsius <= 25.00)
{
digitalWrite(led_green, HIGH);
digitalWrite(led_red, LOW);
}
else
{
digitalWrite(led_green, LOW);
digitalWrite(led_red, HIGH);
}
delay(10000);
}
and this schema:
Temperature 1,2 or 3 degree plus than normal where or what I miss?