const int temp_trans_pin = A0 , Heater_pin = 8, FAN_pin = 6;
/*FAN_pin: here I used DC motor instead of FAN because I couldn't find the symbol for it.Similarly, for the Heater (Heater_pin), I used LED.*/
//Set the range of desired temperature
float MinTemp = 20, 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);
void setup() {
//Sysytem 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 Temperature(C):");
LCD.setCursor (2,1);
LCD.print (MinTemp); LCD.print("-");LCD.print (MaxTemp);
delay (2000)
}
void loop(){
float Eqv_volt, SensorTemp;
//Read voltage and convert to temperature (Celcius)
Eqv_volt = analogRead(temo_trans_pin) *5.0 / 1023;
SensorTemp = 100.0 * Eqv_volt-50.0;
// Display the sensor reading
LCD.clear();
LCD.print("Sensor reading:");
LCD.setCursor(2,1);
LCD.print(SensorTemp);LCD.print("C");
delay(2000)
/*Compare the sensor reading with the range of acceptable temperature*/
if (SensorTemp > MaxTemp) {
LCD.clear();
LCD.print ("Temp is Higher!");//higher than the max
/*Turn on FAN (DC Motor)! to regulate the temp.
Increase FAN speed at slow rate*/
LCD.setCursor(0, 1); LCD.print("Turn On Fan!");
for (int i = 0; i <= 255; i ++) {
analogWrite (FAN_pin, i);
}
delay(2000)
}
else if (SensorTemp < MinTempt) {
LCD.clear();
LCD.print("Temp is LOWER!");//Less than the mini
LCD.setCursor(0, 1);
LCD.print("Turn on Heater");
//Turn on the heater, LED in our case
digitalWrite(Heater_pin, HIGH);
delay(3000)
}
else if (SensorTemp > MinTemp && SensorTemp < MaxTemp) {
/*Now Temperature is Perfect.That is, it is in the desired range. Hence no need changes!!*/
LCD.clear();
LCD.print("Temp is NORMAL!");
LCD.setCursor(2, 1);
LCD.print("Turn Off All !");
delay(1000);
LCD.clear()
}
else {
LCD.clear();
LCD.Print("Something went");
LCD.setCursor(2, 1);
LCD.print("WRONG in the CKT");
delay(1000);
LCD.clear()
}
delay(1000);
}
expected unqualified-id before 'if' at coding below
.. HELP
if (SensorTemp > MaxTemp) {
LCD.clear();
LCD.print ("Temp is Higher!");//higher than the max
/Turn on FAN (DC Motor)! to regulate the temp.
Increase FAN speed at slow rate/
LCD.setCursor(0, 1); LCD.print("Turn On Fan!");
for (int i = 0; i <= 255; i ++) {
analogWrite (FAN_pin, i);
}
delay(2000)
}
