Temperature based fan controller using arduino






Materials:-

Diagram:-



Connections:-

LCD display to arduino
  • Vss = Arduino GND
  • VDD = Arduino 5V
  • V0 = Potentiometer center pin
  • RS = Digital pin  2
  • RW = Arduino GND
  • E =   Digital pin 3
  • D4 = Arduino digital pin  4
  • D5  = Arduino digital pin 5
  • D6 = Arduino digital pin 6
  • D7 = Arduino digital pin 7
  • A = Arduino  5V
  • K = Arduino GND
    Potentiometer to arduino
    •   Left pin  = Arduino GND
    •   Right pin = Arduino 5v
    • center pin = Display VO 
    temperature sensor(LM35) to arduino
    • Sensor VCC = Arduino 5V
    • Sensor GND = Arduino GND
    • Sensor center = Arduino A0

    Relay module to arduino
    • Sensor VCC = Arduino 5V
    • Sensor GND = Arduino GND
    • Sensor center = Arduino D13

    Downloads:-

    Code


    #include <LiquidCrystal.h>
    LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
    int tempin = A0; // the output pin of LM35
    int temp;
    int cel;
    int tempmin = 69.632;
    int fan = 13;
    void setup() {
      pinMode(tempin, INPUT);
      Serial.begin(9600);
      lcd.begin(16, 2);
      pinMode(fan, OUTPUT);

    }

    void loop() {
      temp = analogRead(tempin);
      cel = temp * 0.48828125;
      Serial.print(cel);
      Serial.println();
      if (tempmin < temp) {
        lcd.setCursor(0, 1);// move cursor to next line
        lcd.print("fan status : ");
        lcd.print("ON"); // display the temperature
        digitalWrite(fan, LOW);
      }



      else {
        lcd.setCursor(0, 1);// move cursor to next line
        lcd.print("fan status : ");
        lcd.print("OFF"); // display the temperature
        digitalWrite(fan, HIGH);
      }


      lcd.setCursor(0, 0);
      lcd.print("temperature: ");
      lcd.print(cel); // display the temperature
      lcd.print("C ");
      delay(200);
      lcd.clear();

    }