Sensor de Temperatura
Aqui fica a montagem de um Sensor de Temperatura com um LM35 aqui fica o video:
Visitem também a minha página: www.desenrasca.pt.vu cumprimentos!
Vídeo do YouTube:


Material:
1 LM35 - Data Sheet
3 leds
3 resistências de 220 ohm
20cm fio condutor
1 breadboard
1 arduino
Esquema de Ligações:

Para ligarem o LM35 devem seguir o seguinte datasheet:

Os leds vão variando conforme a temperatura que o LM35 está a obter poderíamos assim monitorizar a temperatura num ambiente fechado e observar como se encontra a temperatura de uma forma mais directa vendo os 3 leds, se está uma temperatura boa, razoável ou critica.
Código:
int pin = 0; // analog pin
int tempc = 0,tempf=0; // temperature variables
int samples[8]; // variables to make a better precision
int maxi = -100,mini = 100; // to start max/min temperature
int i;
void setup()
{
Serial.begin(9600); // start serial communication
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
}
void loop()
{
for(i = 0;i<=7;i++){ // gets 8 samples of temperature
samples[i] = ( 5.0 * analogRead(pin) * 100.0) / 1024.0;
tempc = tempc + samples[i];
delay(100);
}
tempc = tempc/8.0; // better precision
tempf = (tempc * 9)/ 5 + 32; // converts to fahrenheit
if(tempc > maxi) {maxi = tempc;} // set max temperature
if(tempc < mini) {mini = tempc;} // set min temperature
if(tempc < 19)
{
digitalWrite(13, HIGH); // set the green LED on
digitalWrite(12, LOW);
digitalWrite(11, LOW);
}
if(tempc > 22)
{
digitalWrite(12, HIGH); // set the red LED on
digitalWrite(13, LOW);
digitalWrite(11, LOW);
}
if((tempc > 19) && (tempc < 22))
{
digitalWrite(11, HIGH); // set the yelow LED on
digitalWrite(12, LOW);
digitalWrite(13, LOW);
}
Serial.print(tempc,DEC);
Serial.print(" Celsius, ");
Serial.print(tempf,DEC);
Serial.print(" fahrenheit -> ");
Serial.print(maxi,DEC);
Serial.print(" Max, ");
Serial.print(mini,DEC);
Serial.println(" Min");
tempc = 0;
delay(100); // delay before loop
}