// Include the necessary libraries
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <DHT.h>

#define DHTPIN1 2
#define DHTPIN2 3
#define DHTTYPE DHT22
#define MIN_TEMP 10

DHT dht1(DHTPIN1, DHTTYPE);
DHT dht2(DHTPIN2, DHTTYPE);

LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {
  lcd.init();
  lcd.backlight();
  dht1.begin();
  dht2.begin();
}

void loop() {
  float h1 = dht1.readHumidity();
  float t1 = dht1.readTemperature();
  float h2 = dht2.readHumidity();
  float t2 = dht2.readTemperature();
  float fan_speed = 0;

  lcd.setCursor(0, 0);
  lcd.print("Outside: ");
  lcd.setCursor(0, 1);
  lcd.print(t1);
  lcd.print("C ");
  lcd.print(h1);
  lcd.print("%");

delay(4000);

  lcd.setCursor(0, 0);
  lcd.print("Inside: ");
  lcd.setCursor(0, 1);
  lcd.print(t2);
  lcd.print("C ");
  lcd.print(h2);
  lcd.print("%");

  delay(4000);

  if (t2 > MIN_TEMP) {
     fan_speed = map(t2, MIN_TEMP, t1, 0, 10);
  }
  analogWrite(9, fan_speed);
  delay(1000)

;}