#include <Adafruit_SSD1306.h>
#include <DHT.h>

#define LED_MERAH 8
#define LED_BIRU 9
#define LED_KUNING 10
#define DHTPIN 2     
#define DHTTYPE DHT22   

DHT dht(DHTPIN, DHTTYPE);

int buzzerPin = 7;


void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial.println(F("Suhu Test!"));
  dht.begin();

  pinMode(LED_MERAH, OUTPUT);
  pinMode(LED_BIRU, OUTPUT);
  pinMode(LED_KUNING, OUTPUT);
  pinMode(buzzerPin, OUTPUT);

  digitalWrite(LED_MERAH,LOW);
  digitalWrite(LED_BIRU,LOW);
  digitalWrite(LED_KUNING,LOW);

   
}

void loop() {
  // put your main code here, to run repeatedly:
  delay(2000);
  float t = dht.readTemperature();

  Serial.print("Suhu: ");
  if (t > 35) 
    {
    Serial.println("SUHU PANAS");
    digitalWrite(LED_MERAH, HIGH);
    digitalWrite(LED_BIRU, LOW);
    digitalWrite(LED_KUNING, LOW);
      tone(buzzerPin, 150);
      delay(1000);

    noTone(buzzerPin);
    } 
  else if (t < 29)
    {
    Serial.println("SUHU RENDAH");
    digitalWrite(LED_MERAH, LOW);
    digitalWrite(LED_BIRU, HIGH);
    digitalWrite(LED_KUNING, LOW);
    } 
    else 
    {
    Serial.println("SUHU CUKUP");
    digitalWrite(LED_MERAH, LOW);
    digitalWrite(LED_BIRU, LOW);
    digitalWrite(LED_KUNING, HIGH);
    }

}