LM335Z Temperature Sensor

Hi!
I hve a problem with my sketch for a temperature regulator with relays.

The sketch that I’m using is:
//Climatizador

const int amb=25; //Declares constant T°
const int vent=3; //Declares pin for electric fan
const int estu=2; //Declares pin for heater
int AN4=A4; //Declares analog INPUT in A4

void setup(){
pinMode(vent, OUTPUT);
pinMode(estu, OUTPUT);
pinMode(AN4, INPUT);
}
void loop()
{
AN4=analogRead(A4); // Analog connection of LM35
AN4=(AN4*500.0)/1024.0; //Calculates T° in C°
Serial.println(AN4);
if(AN4<amb) //Si la temperatura es menor a 25ºC { digitalWrite(estu, HIGH); //Activa el rele de la estufa digitalWrite(vent, LOW); //Desactiva el del ventilador } else if(AN4>amb) //Si la temperatura es mayor a 25ºC
{
digitalWrite(vent, HIGH); //Activa el rele del ventilador
digitalWrite(estu, LOW); //Desactiva el rele de la estufa
}
else //En cualquier otro caso, ambos estan desactivados
{
digitalWrite(vent, LOW);
digitalWrite(estu, LOW);
}
delay(180000); //Retardo entre medicion y medicion de 3min
}
Please sorry me if I don’t know how to attach the sketch, I’m really noob in the forum :frowning:
However, this sketch have (has? sorry for the bad english) this lines:
AN4=analogRead(A4); // Analog connection of LM35
AN4=(AN4*500.0)/1024.0; //Calculates T° in C°
But, I’ve got the LM335Z sensor that gives the temperature level in kelvin
I have this sketch from a simple-temperature-monitor
float tempK=0, tempC=0;
void setup(){
**Serial.begin(9600); **
}
void loop(){
tempK = analogRead(0) * 0.004882812 * 100; //reads the temperatura in Kelvin
tempC = tempK - 273.15; //Converts Kelvin to C°
**//Se imprime el valor **
Serial.println(tempC);
delay(1000); //Luego de 1 segundo se toma la siguiente lectura
}
How can I put this lines:
tempK = analogRead(0) * 0.004882812 * 100; //reads the temperatura in Kelvin
tempC = tempK - 273.15; //Converts Kelvin to C°
into the first sketch in order to use the LM335Z and not the LM35?
Thanks and again, I’m really sorry if I made a mistake in my message.My english domain is not very good :S
Bye:)

replace the two lines in the original sketch with the two lines for your sensor.

Then assign tempC to AN4.

Or, alternatively, use tempC instead of AN4 at the other lines in the program where it is mentioned.