ambhatt
Published © LGPL

Temperature Controlled Fan with LCD Using Arduino

The Arduino controls the fans speed as per room temperature and also displays temperature on an LCD.

IntermediateFull instructions provided27,349
Temperature Controlled Fan with LCD Using Arduino

Things used in this project

Hardware components

DC Motor, Miniature
DC Motor, Miniature
×1
Alphanumeric LCD, 20 x 4
Alphanumeric LCD, 20 x 4
×1
Gravity: Analog LM35 Temperature Sensor For Arduino
DFRobot Gravity: Analog LM35 Temperature Sensor For Arduino
×1
Rotary Potentiometer, 10 kohm
Rotary Potentiometer, 10 kohm
×1
Arduino UNO
Arduino UNO
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Breadboard, 270 Pin
Breadboard, 270 Pin

Story

Read more

Schematics

Arduino based temperature controlled FAN

it controls fan speed as per the room temperature

Code

Temperature controlled FAN program

C/C++
it varies fan speed as per set temperature
#include <LiquidCrystal.h>
# define temp_sensor_pin A0
# define ref_pin A1
#define fan_op_pin 9
#define red_led 6
#define green_led 7
#define blue_led 8
#define sound_pin 10
float temperature;
int fan_speed = 50;
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() 
{
    Serial.begin(9600);
    lcd.begin(16, 4);
    lcd.clear();
    lcd.print("set temp:");
    lcd.setCursor(0,1);
    lcd.print("cur temp:");
    pinMode(red_led,OUTPUT);
    pinMode(green_led,OUTPUT);
    pinMode(blue_led,OUTPUT);
    analogWrite(fan_op_pin, fan_speed);
}

void loop() 
  {
  	int sensor_value,ref_value,max_temp_limit,min_temp_limit;
  	sensor_value = analogRead(temp_sensor_pin);    // get the sensor reading
  	ref_value = analogRead(ref_pin); 
  	ref_value = map(ref_value, 0, 1023, 0, 100);
  	max_temp_limit = ref_value+5;
  	min_temp_limit = ref_value-5;
  	temperature = (5*sensor_value)/10.31;
  	Serial.print("set temperature is ");
  	Serial.println(ref_value);
   	Serial.print("current temperature is ");
  	Serial.println(temperature);
  	lcd.setCursor(9,0); 
  	lcd.print(ref_value);
  	lcd.print("*C"); 
  	lcd.setCursor(9,1);   // set cursor to 2nd line 1st column
  	lcd.print(temperature); // print temperature
  	lcd.print("*C");   
  	if(temperature > max_temp_limit) 
    	  {
      		lcd.setCursor(0,2);
      		lcd.print("over temperature");
      		lcd.setCursor(0,3);
      		lcd.print("fan speed incr");
      		if(fan_speed<150) fan_speed += 20;
      		analogWrite(fan_op_pin, fan_speed);
      		digitalWrite(red_led,HIGH);
      		digitalWrite(green_led,LOW);
      		digitalWrite(blue_led,LOW);
      		tone(sound_pin,1245,1000); 
    	  } 
   	else if(temperature < min_temp_limit) 
    	  {
      		lcd.setCursor(0,2);
      		lcd.print("temperature down");
      		lcd.setCursor(0,3);
      		lcd.print("fan speed decr");
     		if(fan_speed > 50) fan_speed-=20;
      		analogWrite(fan_op_pin, fan_speed);
      		digitalWrite(red_led,LOW);
      		digitalWrite(green_led,LOW);
      		digitalWrite(blue_led,HIGH);
       	tone(sound_pin,1245,1000); 
      }
   else if((temperature<max_temp_limit) && (temperature>min_temp_limit))
    {  
       lcd.setCursor(0,2);
       lcd.print("temperature is  ");
       lcd.setCursor(0,3);
       lcd.print("within limit  "); 
       digitalWrite(red_led,LOW);
      digitalWrite(green_led,HIGH);
      digitalWrite(blue_led,LOW);
    }
  delay(1000);      // 1 sec delay
}

Credits

ambhatt

ambhatt

5 projects • 39 followers

Comments