/* Programa desenvolvido by Gamesh_
com base no livro Programming Interactivity
13/01/2011
http://brasilrobotics.blogspot.com/
*/
int pin = 0;
int tempc= 0, tempf=0,tempk=0;
int samples[8];
int i;
void setup(){
Serial.begin(9600);
}
void loop(){
for(i = 0; i<=7 ;i++){
samples[i] = ( 5.0 * analogRead(pin) * 100.0) / 1024.0;
tempc = tempc + samples[i]; // somando os 8 valores lidos
delay(1000);
}
tempc = tempc/8.0; // tirando a media dos 8 valores
tempf = (tempc * 9)/ 5 + 32; // converte para fahrenheit
tempk= tempc+273; // converte para Kelvin
delay(100);
//Mostra as temperaturas em C F e K
Serial.print("TemperaturaC:");
Serial.print(tempc);
Serial.print("\\t");
Serial.print("TemperaturaF:");
Serial.print(tempf);
Serial.print("\\t");
Serial.print("TemperaturaK:");
Serial.print(tempk);
Serial.print("\\n");
}