sci-oly-detector-building

[RADIOACTIVE] arduino thermometer for science olympiad
git clone git://git.figbert.com/sci-oly-detector-building.git
Log | Files | Refs | LICENSE

ThermistorDemo.ino (1602B)


      1 /* Sensor test sketch
      2   for more information see http://www.ladyada.net/make/logshield/lighttemp.html
      3   */
      4  
      5 #define aref_voltage 3.3         // we tie 3.3V to ARef and measure it with a multimeter!
      6  
      7  
      8  
      9  
     10 //TMP36 Pin Variables
     11 int tempPin = 1;        //the analog pin the TMP36's Vout (sense) pin is connected to
     12                         //the resolution is 10 mV / degree centigrade with a
     13                         //500 mV offset to allow for negative temperatures
     14 int tempReading;        // the analog reading from the sensor
     15  
     16 void setup(void) {
     17   // We'll send debugging information via the Serial monitor
     18   Serial.begin(9600);   
     19  
     20   // If you want to set the aref to something other than 5v
     21   analogReference(EXTERNAL);
     22 }
     23  
     24  
     25 void loop(void) {
     26  
     27   tempReading = analogRead(tempPin);  
     28  
     29   Serial.print("Temp reading = ");
     30   Serial.print(tempReading);     // the raw analog reading
     31  
     32   // converting that reading to voltage, which is based off the reference voltage
     33   float voltage = tempReading * aref_voltage;
     34   voltage /= 1024.0; 
     35  
     36   // print out the voltage
     37   Serial.print(" - ");
     38   Serial.print(voltage); Serial.println(" volts");
     39  
     40   // now print out the temperature
     41   float temperatureC = (voltage - 0.5) * 100 ;  //converting from 10 mv per degree wit 500 mV offset
     42                                                //to degrees ((volatge - 500mV) times 100)
     43   Serial.print(temperatureC); Serial.println(" degrees C");
     44  
     45   // now convert to Fahrenheight
     46   float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
     47   Serial.print(temperatureF); Serial.println(" degrees F");
     48  
     49   delay(1000);
     50 }