// Log sun and temperature // Copyright 2009 Ken Shirriff // http://arcfn.com // // A photocell is connected to analog input SUN_PIN // A TMP036 sensor is connected to analog input TEMP_PIN // The sketch writes lines of the form: // 32.82 956 // where the first number is the temperature in degrees C // and the second line is the sun in arbitrary units 0-1023. #define SUPPLY 5.14 // Supply voltage (measured) #define TEMP_PIN 0 // Pin with temperature #define SUN_PIN 2 // Pin with photocell void setup() { Serial.begin(9600); } void loop() { float v = analogRead(TEMP_PIN) * SUPPLY / 1024; float c = (v - .5) * 100; Serial.print(c); Serial.print(" "); Serial.println(analogRead(SUN_PIN), DEC); delay(5000); }