Introduction
- In this article, I will explain about controlling the fan by temperature sensor by using Arduino Mega 2560.
- In the range, it can be controlled by the fixed temperature so that it can easily be done.
Parts Of Lists
- Arduino Mega 2560
- Fan or a servo motor
- LM35
- Bread Board
- Hookup Wires.
Connection
Step 1 Connect the ServoMotor To the Arduino Mega 2560
- Connect the Vcc of the Servo Motor to the 5v of the Arduino Mega 2560.
- Connect the gnd of the Bluetooth to the Gnd of the Arduino Mega 2560.
- Connect the Vin of the Bluetooth to the 09 of the Arduino Mega 2560.
Step 2 Connect the Temperature Sensor To The Arduino mega 2560
- The first pin can be connected to the Vcc of the 5V to an Arduino board.
- The second pin can be connected to the A1 of the analog side to an Arduino board.
- The third pin can be connected to the Gnd to an Arduino board.
Programming
- float temp;
- int tempPin = A1; //arduino pin used for temperature sensor
- int tempMin = 25; // the temperature to start the buzzer
- int tempMax = 70;
- int fan = 9; // the pin where fan is connected
- int fanSpeed = 0;
- void setup()
- {
- pinMode(fan, OUTPUT);
- pinMode(tempPin, INPUT);
- Serial.begin(9600);
- }
- void loop()
- {
- temp = analogRead(tempPin);
- temp = (temp * 5.0 * 100.0) / 1024.0; //calculate the temperature in Celsius
- Serial.println(temp);
- delay(1000); // delay in between reads for stability
- if (temp < tempMin)
- {
- // if temp is lower than minimum temp
- fanSpeed = 0; // fan is not spinning
- digitalWrite(fan, LOW);
- }
- if ((temp >= tempMin) && (temp <= tempMax)) //if temperature is higher than the minimum range
- {
- fanSpeed = map(temp, tempMin, tempMax, 32, 255); // the actual speed of fan
- analogWrite(fan, fanSpeed); // spin the fan at the fanSpeed speed
- }
- }
- In this article, I explained the temperature based fan control
- When the fan is ON/OFF it has been based on the temperature I have fixed.
- When the temperature is low it can be started.
- When the temperature is high it can be stopped.

Anu VPosted Jul 9, 2016, 12:16 AM
Nice share.
Shobana JPosted Jul 8, 2016, 4:09 AM
Keep sharing.Nice one
Sr KarthigaPosted Jul 5, 2016, 10:40 AM
Thank you santhakumar sir
Sr KarthigaPosted Jul 5, 2016, 10:40 AM
Thank you prasanna bro
Sr KarthigaPosted Jul 5, 2016, 10:39 AM
Thank you rakesh bro
Sr KarthigaPosted Jul 5, 2016, 10:39 AM
Thank you raja
Sr KarthigaPosted Jul 5, 2016, 10:39 AM
Thyank you debasis sir
Santhakumar MunuswamyPosted Jun 25, 2016, 3:13 AM
Nice share
Prasanna MuraliPosted Jun 21, 2016, 9:33 PM
Nice one..
RakeshPosted Jun 13, 2016, 11:39 AM
Nice one
RajaPosted Jun 13, 2016, 12:35 AM
Great Share...
Debasis SahaPosted Jun 13, 2016, 12:15 AM
Nice share..
Sr KarthigaPosted Jun 11, 2016, 9:55 PM
thank you vignesh sir
Vignesh ManiPosted Jun 11, 2016, 4:28 PM
good one