document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. /* Programa desenvolvido by Gamesh_
  2.  
  3. com base no livro Programming Interactivity
  4.  
  5. 13/01/2011
  6.  
  7. http://brasilrobotics.blogspot.com/
  8.  
  9. */
  10.  
  11. int pin = 0;
  12. int tempc= 0, tempf=0,tempk=0;
  13. int samples[8];
  14. int i;
  15.  
  16. void setup(){
  17.  
  18. Serial.begin(9600);
  19.  
  20. }
  21.  
  22. void loop(){
  23.  
  24. for(i = 0; i<=7 ;i++){
  25. samples[i] = ( 5.0 * analogRead(pin) * 100.0) / 1024.0;
  26. tempc = tempc + samples[i]; // somando os 8 valores lidos
  27. delay(1000);
  28. }
  29.  
  30. tempc = tempc/8.0; // tirando a media dos 8 valores
  31. tempf = (tempc * 9)/ 5 + 32; // converte para fahrenheit
  32. tempk= tempc+273; // converte para Kelvin
  33. delay(100);
  34.  
  35. //Mostra as temperaturas em C F e K
  36. Serial.print("TemperaturaC:");
  37. Serial.print(tempc);
  38. Serial.print("\\t");
  39. Serial.print("TemperaturaF:");
  40. Serial.print(tempf);
  41. Serial.print("\\t");
  42. Serial.print("TemperaturaK:");
  43. Serial.print(tempk);
  44. Serial.print("\\n");
  45.  
  46. }
');