#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#include <DHT.h>
#define TFT_DC 9
#define TFT_CS 10
#define DHTPIN 2
#define DHTTYPE DHT22
#define BUZZER_PIN 3
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
DHT dht(DHTPIN, DHTTYPE);
void setup() {
pinMode(BUZZER_PIN, OUTPUT);
Serial.begin(9600);
dht.begin();
tft.begin();
tft.setCursor(26, 120);
tft.setTextColor(ILI9341_RED);
tft.setTextSize(3);
tft.println("Welcome to");
tft.setCursor(26, 160);
tft.println("M OS V1!");
tft.setCursor(20, 200);
tft.setTextColor(ILI9341_GREEN);
tft.setTextSize(2);
tft.println("Boot OS Wait 5s");
delay(5000);
// Meme reference: https://english.stackexchange.com/questions/20356/origin-of-i-can-haz
}
void loop() {
delay(500); // Delay between readings
float temperature = dht.readTemperature(); // Read temperature in Celsius
float humidity = dht.readHumidity();
// Read humidity
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.print(" °C\tHumidity: ");
Serial.print(humidity);
Serial.println(" %");
if (temperature > 50) {
tft.fillScreen(ILI9341_RED);
digitalWrite(BUZZER_PIN, HIGH); // Turn on the buzzer
delay(1000); // Wait for 1 seconds
digitalWrite(BUZZER_PIN, LOW); // Turn off the buzzer
} else {
tft.fillScreen(ILI9341_BLACK);
}
tft.setCursor(26, 120);
tft.setTextColor(ILI9341_RED);
tft.setTextSize(3);
tft.println("Temperature °C");
tft.setCursor(26, 160);
tft.println(temperature);
tft.setCursor(20, 200);
tft.setTextColor(ILI9341_GREEN);
tft.setTextSize(2);
tft.println("Boot OS Wait 5s");
}