Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Control Fan With Temperature Sensor Using Arduino Mega 2560
WhatsApp
Sr Karthiga
4y
23.1k
0
1
100
Article
tempfan.zip
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
}
}
Explanation
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.
Arduino
Arduino Mega 2560
Internet of Things
Temperature Sensor
Up Next
Ebook Download
View all
Raspberry Pi -Sensorial Symphony of Connectivity
Read by 704 people
Download Now!
Learn
View all
Membership not found