Skip to content

Commit

Permalink
Merge pull request prathimacode-hub#238 from DragonUncaged/tempcontro…
Browse files Browse the repository at this point in the history
…lfan

Automatic Fan Speed Control (done Changes)
  • Loading branch information
prathimacode-hub authored May 30, 2022
2 parents 4554fff + eb5cc40 commit 09c088e
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,8,7,6,5);
int tempPin = A0; // Output pin LM35
int fan = 10; // pin
int led = 6; // pin LED
int temp;
int tempMin = 30;
int tempMax = 60;
int fanSpeed;
int fanLCD;
int stop = 2; // pin Interrupt

void setup() {
Serial.begin(9600);
pinMode(fan, OUTPUT);
pinMode(led, OUTPUT);
pinMode(tempPin, INPUT);
lcd.begin(16,2);

pinMode(stop, INPUT_PULLUP);
attachInterrupt (digitalPinToInterrupt (stop), stopfan, HIGH); //digitalPinToInterrupt (stop), HIGH
}

void loop() {
temp = readTemp();
if(temp < tempMin) {
fanSpeed = 0;
digitalWrite(fan, LOW);
}
if((temp >= tempMin) && (temp <= tempMax)) { // if temperature is higher than minimum temp
fanSpeed = map(temp, tempMin, tempMax, 32, 255); // the actual speed of fan
fanLCD = map(temp, tempMin, tempMax, 0, 102); // speed of fan to display on LCD
analogWrite(fan, fanSpeed); // spin the fan at the fanSpeed speed
}
if(temp > tempMax) {
digitalWrite(led, HIGH);
} else {
digitalWrite(led, LOW);
}

lcd.print("TEMP: ");
lcd.print(temp); //Celsius
lcd.print("C ");
lcd.setCursor(0,1);
lcd.print("FANS: ");
lcd.print(fanLCD);
lcd.print("%");
delay(200);
lcd.clear();


}

int readTemp() { Celsius
temp = analogRead(tempPin);
return temp * 0.48828125;
}

void stopfan () {
lcd.clear();
digitalWrite (fan, LOW);
delayMicroseconds(90000000000000000000000);
//lcd display
Serial.println("DragonUncaged");
//initial display for the temperature
lcd.print("TEMP: --");
lcd.setCursor(0,1);
lcd.print("FANS: 0%");

}

Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions Minor Scripts/Arduino/Automatic Fan Speed Control/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Automatic Fan
## AIM:
Temperature Controlled Fan Simulation In Tinker Cad

## Purpose:
To Start the Fan as the Temperature Is Ceratain Temperature is Reached. Also Increse the Fan Speed as the Temperature rises.

## Short Description:
**Requirements:**
- Arduino UNO
- LCD 16X2
- Temperature Sensor (TMP36)
- Potentiometer (50 Kohm)
- Fan
- Push Button
(Tinkercad can also be used)

## Workflow:
- First we initialise TMP36 PIN, Fan Pin.
- We initiate a Conditional statement For the Fan to Start as temperature increases.
- A Resistor (1 Kohm) is added For the LCD and Resistor (10 Kohm) to the push button.

In this circuit we are maintaing the room temperature between 30-45 C using motor. If the temperature is lower than 30 C then Fan will turn on. Once the temperature gets Low it will turn off User can set the range of room temperature by changing in the code.

## Setup instructions:
- Assemble the circuit as shown below.
- Open Tinker Cad on any browser and make the circuit as shown here.
- Then paste the code in code section.
- Open the Serial Monitor.
- Start Simulation.
- Upload the code provided [here]()
- Run to see the project in action!
------------
## Output:
[Simulation Video](./Images/preview.mp4)
![Tinkercad Circuit](./Images/preview1.jpg)
------------

## Author:
[DragonUncaged](https://github.com/dragonuncaged)

0 comments on commit 09c088e

Please sign in to comment.