/* * Temperature Logger with Delphi * ----------------- * Logs the temperature aquired by the LM35 Precision centigrade temperature sensor * connected to Analog Pin 0 and sends the data thru the serial comm. * In this case Delphi will catch the comm on the other end, Arduino will send only the temp value * expresed as a string of 2 digits. * * IMPORTANT!!: Don't forget to download the Delphi PC Example that actually displays the data sent by this arduino code. * * Based on the code of Daniel Spilliere Andrade, http://www.danielandrade.net * * Created April 03 2009 * Roberto Ramirez * Full Source code at http://www.thepenguincult.com/proyectos/arduino-delphi-lm35/ */ int pin = 0; // analog pin int tempc = 0,tempf=0; // temperature variables int samples[8]; // variables to make a better precision int i; void setup() { Serial.begin(9600); // start serial communication } 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(250); } tempc = tempc/8.0; // better precision Serial.print(tempc,DEC); tempc = 0; delay(250); // delay before loop }