Skip to main content

arduino-fan-speed-controlled-temperature


    arduino-fan-speed-controlled-temperature

  1. #include <LiquidCrystal.h>
  1. //source: http://www.electroschematics.com/9540/arduino-fan-speed-controlled-temperature/
  1. LiquidCrystal lcd(7,6,5,4,3,2);
  1. int tempPin = A1; // the output pin of LM35
  1. int fan = 11; // the pin where fan is
  1. int led = 8; // led pin
  1. int temp;
  1. int tempMin = 30; // the temperature to start the fan
  1. int tempMax = 70; // the maximum temperature when fan is at 100%
  1. int fanSpeed;
  1. int fanLCD;
  1.  
  1. void setup() {
  1. pinMode(fan, OUTPUT);
  1. pinMode(led, OUTPUT);
  1. pinMode(tempPin, INPUT);
  1. lcd.begin(16,2);
  1. }
  1.  
  1. void loop() {
  1. temp = readTemp(); // get the temperature
  1. if(temp < tempMin) { // if temp is lower than minimum temp
  1. fanSpeed = 0; // fan is not spinning
  1. digitalWrite(fan, LOW);
  1. }
  1. if((temp >= tempMin) && (temp <= tempMax)) { // if temperature is higher than minimum temp
  1. fanSpeed = map(temp, tempMin, tempMax, 32, 255); // the actual speed of fan
  1. fanLCD = map(temp, tempMin, tempMax, 0, 100); // speed of fan to display on LCD
  1. analogWrite(fan, fanSpeed); // spin the fan at the fanSpeed speed
  1. }
  1. if(temp > tempMax) { // if temp is higher than tempMax
  1. digitalWrite(led, HIGH); // turn on led
  1. } else { // else turn of led
  1. digitalWrite(led, LOW);
  1. }
  1. lcd.print("TEMP: ");
  1. lcd.print(temp); // display the temperature
  1. lcd.print("C ");
  1. lcd.setCursor(0,1); // move cursor to next line
  1. lcd.print("FANS: ");
  1. lcd.print(fanLCD); // display the fan speed
  1. lcd.print("%");
  1. delay(200);
  1. lcd.clear();
  1. }
  1.  
  1. int readTemp() { // get the temperature and convert it to celsius
  1. temp = analogRead(tempPin);
  1. return temp * 0.48828125;
  1. }

Comments

Popular posts from this blog

Jio

Reliance Jio planning its own  cryptocurrency called JioCoin  elder son Akash Ambani leading the JioCoin project, Reliance Jio plans to build a 50-member team of young professionals to work on blockchain technology, which can also be used to develop applications such as smart contracts and supply chain management logistics

garbage monitoring using arduino code with gsm

#include <SoftwareSerial.h> #include <LiquidCrystal.h> //LiquidCrystal lcd(7, 6, 5, 4, 3, 2); LiquidCrystal lcd(13, 12, 11, 10, 9, 8); SoftwareSerial mySerial(0,1); #define trigPin 2 #define echoPin 3 #define PIR_sensor 4 #define m11 5 #define m12 6 void setup() {    lcd.begin(16, 2);    lcd.print("    Garbage    ");    Serial.println("garbage ");   lcd.setCursor(0,1);   lcd.print("   Open Close    ");   Serial.println(" open close");   delay(3000);   lcd.clear();   //lcd.print(" ");   delay(2000); mySerial.begin(9600); // Setting the baud rate of GSM Module Serial.begin (9600); pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT);  pinMode(m11, OUTPUT);   pinMode(m12, OUTPUT);   } void loop() {  readPIR();  pingDist();  SendMessage(); } void pingDist ()   {     long duration, distance;...