/* File to be named LCDTemp01 Temperature Sensor Reading temperature with LM35 sensor. Coded by: arduinoprojects101.com Ollie Edited 01 */ // include the library code: #include // initialize the library with the numbers of the interface pins LiquidCrystal lcd(7, 8, 9, 10, 11, 12); //declare variables float tempC; float tempF; float Thigh; float Tlow; int tempPin = 1; void setup(){ // set up the LCD's number of columns and rows: lcd.clear(); lcd.begin(16, 2); lcd.print("C= TH="); lcd.setCursor(0, 1); lcd.print("F= TL="); Tlow=98; // Initially sets the Tlow to something outragiously high. // Without this it would default to 0.0 // For Digital out test pinMode(6, OUTPUT); // Defines pin13 as a digital output digitalWrite(6, HIGH); } void loop(){ // Temperature Calculations tempC = analogRead(tempPin); //read the value from the sensor tempC = (5.0 * tempC * 100.0)/1024.0; //convert the analog data to temperature tempF = ((tempC*9)/5) + 32; //convert celcius to farenheit // Determines and Sets Thigh and Tlow values if (Thigh < tempF){ //Checks to see if the Htemp is less than the current temp tempF Thigh = tempF; // if so, it makes Htemp the same as tempF } if (Tlow > 94){ // 1. This the check to see if the program ha passed thru here already // 2. If it has not, it will change the 98 value to current tempF Tlow = tempF; // 3. here. This condition can only be met on the first pass. } if (Tlow > tempF){ //After the program runs the loop the first time, line 1. will not be met Tlow = tempF; //Normal check for lower temp. This will constantly. } // External Digital Signal .. LED or Relay Uses Digital pin 13 on Arduino if (tempF > 84) { digitalWrite(6, LOW); } else { digitalWrite(6,HIGH); } // digitalWrite(6, HIGH); // turn the LED on (HIGH is the voltage level) // delay(100); // digitalWrite(6, LOW); // turn the LED off by making the voltage LOW // delay(100); // print result to lcd display lcd.setCursor(2, 0); lcd.print(tempC,1); lcd.setCursor(10, 0); lcd.print(Thigh,2); // the fix for loosing the right dec is changing the 0 to 1 lcd.setCursor(2, 1); lcd.print(tempF,1); lcd.setCursor(10, 1); lcd.print(Tlow,2); // sleep... delay(1000); }