loosu
Published © Apache-2.0

Automatic FAN and light controlled

An automatic fan controlled using thermistors.

AdvancedShowcase (no instructions)7,399
Automatic FAN and light controlled

Things used in this project

Code

Automatic home fan controlled

Arduino
#include <math.h>
#include <LiquidCrystal.h>

LiquidCrystal lcd(1,2,4,5,6,7);
int pinOut = 10;
int ledpin=13;
int buttonpin=8;

double Thermistor(int RawADC) {
 double Temp;
 Temp = log(10000.0*((1024.0/RawADC-1))); 
 Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
 Temp = Temp - 273.15;          
 //Temp = (Temp * 9.0)/ 5.0 + 32.0; 
 return Temp;
}

void setup() {
  pinMode(10, OUTPUT);
 lcd.begin(16, 2);
 //Serial.begin(9600);
 pinMode(ledpin,OUTPUT);
 pinMode(buttonpin,INPUT);
}

void loop() {             
  int val;                
  double temp;            
  val=analogRead(0);      
  temp=Thermistor(val); 
  //Serial.print("Temperature=");
  //Serial.print(temp);
  //Serial.println(" c");
  

  lcd.setCursor(2,1); 
  lcd.print("Temp = ");
    lcd.print(temp);   
  lcd.print(" c");
  delay(5000);            
  lcd.clear();
  if (temp >= 40){
    digitalWrite(pinOut, HIGH);
    lcd.print("Fan on");
    delay(1000);
  }

  else {
    digitalWrite(pinOut, LOW);
    lcd.print(" Fanoff");
  
       delay(500); 
  }
          
     if(digitalRead(buttonpin)==1){
    digitalWrite(ledpin,HIGH);
      
        lcd.print(" LED on");
        delay(1000);
  } 
     
  else {
   
      digitalWrite(ledpin,LOW);
    lcd.print("LED off");
    delay(500); 
  }
             
}

Credits

loosu
4 projects • 4 followers

Comments