// Declare/assign Arduino IO-pins
const int temp_trans_pin = A0, Heater_pin = 13, FAN_pin = 6;
/*FAN_pin: here I used DC motor in stead of FAN because
I couldn't find the symbol for it. Similarly,for the
Heater (Heater_pin), I used LED.*/
// Set the range of the desired temperature
float MaxTemp = 25;/*Room temperature is [20,25] degree C */
// Include the LCD library code
#include <LiquidCrystal.h>
// Initialize the library with the numbers of the interface pins
LiquidCrystal LCD(12, 11, 5, 4, 3, 2);
float temp=0.0;
float procent=0.0;
int potency;
void setup() {
// System initialization
LCD.begin(16, 2);
pinMode(Heater_pin, OUTPUT);//LED in our case
// pinMode(FAN_pin, OUTPUT);
// Display the desired range of temperature
LCD.print("Room temp(C):");
LCD.setCursor(2,1);
//LCD.print(MinTemp); LCD.print("-");LCD.print(MaxTemp);
delay(2000);
}
void loop() {
float Eqv_volt, SensorTemp;
int analog_value = analogRead(A1);
temp = (analog_value * 5.0) / 1023.0;
procent = temp*20;
potency = map(analogRead(A2), 0, 1023, 0, 270);
Eqv_volt = analogRead(temp_trans_pin) * 5.0 / 1023;
SensorTemp = 100.0 * Eqv_volt-50.0;
// Display the sensor reading
/*Compare the sensor reading with the range of
acceptable temperatures*/
if(SensorTemp > MaxTemp){
digitalWrite(Heater_pin, LOW);
LCD.clear();
LCD.print("High T!");//higher than the max
LCD.setCursor(11,0);
LCD.print("Set T");
LCD.setCursor(13,1);
LCD.print("25");
Serial.print("v%");
Serial.println(temp);
LCD.setCursor(6, 0);
LCD.print("V% ");
LCD.setCursor(5, 1);
LCD.print(procent);
LCD.print("%");
delay(4000);
delay(4000);
}
else if(SensorTemp < MaxTemp){
LCD.clear();
LCD.print("Low T");//Less than the mini
LCD.setCursor(0, 1);
LCD.print("H On");
LCD.setCursor(11,0);
LCD.print("Set T");
LCD.setCursor(13,1);
LCD.print("25");
Serial.print("v%");
Serial.println(temp);
LCD.setCursor(6, 0);
LCD.print("V% ");
LCD.setCursor(5, 1);
LCD.print(procent);
LCD.print("%");
delay(4000);
//Turn the heater ON, LED in our case
digitalWrite(Heater_pin, HIGH);
delay(4000);
}
}