Ramji Patel
Published © GPL3+

Temperature Controlled Fan

LM35 Temperature controlled Fan

IntermediateFull instructions provided2,994
Temperature Controlled Fan

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
Solderless Breadboard Full Size
Solderless Breadboard Full Size
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Gravity: Analog LM35 Temperature Sensor For Arduino
DFRobot Gravity: Analog LM35 Temperature Sensor For Arduino
×1
Linear Regulator (7805)
Linear Regulator (7805)
×1
MOSFET Transistor, Switching
MOSFET Transistor, Switching
×1
Axial Fan, 12 VDC
Axial Fan, 12 VDC
×1
Buzzer
Buzzer
×1
General Purpose Transistor NPN
General Purpose Transistor NPN
×1
Capacitor 100 µF
Capacitor 100 µF
×1
Capacitor 100 nF
Capacitor 100 nF
×1
Resistor 1k ohm
Resistor 1k ohm
×1
Multi-Turn Precision Potentiometer- 10k ohms (25 Turn)
Multi-Turn Precision Potentiometer- 10k ohms (25 Turn)
×1
Resistor 100 ohm
Resistor 100 ohm
×1
9V battery (generic)
9V battery (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Extraction Tool, 6 Piece Screw Extractor & Screwdriver Set
Extraction Tool, 6 Piece Screw Extractor & Screwdriver Set
Soldering Station, 110 V
Soldering Station, 110 V

Story

Read more

Schematics

LM35 Temperature Fan

Copy my code and paste it on Your editor

Code

LM35 Temperature Fan

Arduino
copy and paste
// Ramji Patel376 //
// Arduino.cc //

#include <LiquidCrystal.h>
LiquidCrystal lcd(5,6,7,8,9,10);

int tempPin = A4; // the output pin of LM35
int fan = 3; // the pin where fan is
int led = 12; // led pin
int temp;
int tempMin = 30;          // the temperature to start the fan 0%
int tempMax = 60;         // the maximum temperature when fan is at 100%
int fanSpeed;
int fanLCD;
int buzzer = 13;
 
void setup() {
pinMode(fan, OUTPUT);
pinMode(led, OUTPUT);
pinMode(tempPin, INPUT);
lcd.begin(16,2);
Serial.begin(9600);
}
 
void loop()
{
temp = readTemp();            // get the temperature
Serial.print( temp );
if(temp < tempMin)           // if temp is lower than minimum temp
{
fanSpeed = 0;               // fan is not spinning
analogWrite(fan, fanSpeed);
fanLCD=0;
digitalWrite(fan, LOW);
}
if((temp >= tempMin) && (temp <= tempMax))         // if temperature is higher than minimum temp
{
fanSpeed = temp;//map(temp, tempMin, tempMax, 0, 100);       // the actual speed of fan//map(temp, tempMin, tempMax, 32, 255);
fanSpeed=1.5*fanSpeed;
fanLCD = map(temp, tempMin, tempMax, 0, 100);          // speed of fan to display on LCD100
analogWrite(fan, fanSpeed);            // spin the fan at the fanSpeed speed
}
 
if(temp > tempMax)          // if temp is higher than tempMax
{
digitalWrite(led, HIGH);     // turn on led
}
else // else turn of led
{
digitalWrite(led, LOW);
}
lcd.setCursor(0,0);
lcd.print("TEMP: ");
lcd.print(temp);          // display the temperature
lcd.print("C ");
lcd.setCursor(0,1);      // move cursor to next line
lcd.print("FANS: ");
lcd.print(fanLCD);      // display the fan speed
lcd.print("%");

}
 
int readTemp() {
  // get the temperature and convert it to celsius
temp = analogRead(tempPin);
return temp * 0.48828125;
}

Credits

Ramji Patel
26 projects • 20 followers
Myself Ramji Patel. I am an Engineering student and pursuing my B-Tech from Institute of engineering and rural Technology Prayagraj, India.

Comments