// variables
int pinled0 = 11;
int pinled1 = 12;
int pinled2 = 13;
#define buzz_pin 3
#include <DHT.h>
#define DHTPIN 2
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
void setup() {
// put your setup code here, to run once:
pinMode(pinled0, OUTPUT);
pinMode(pinled1, OUTPUT);
pinMode(pinled2, OUTPUT);
pinMode(buzz_pin,OUTPUT);
dht.begin();
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
float temperatura = dht.readTemperature();
tone(buzz_pin, 1000);
if (temperatura >= 5 && temperatura < 17) {
digitalWrite(pinled0, HIGH);
digitalWrite(pinled1, LOW);
digitalWrite(pinled2, LOW);
noTone(buzz_pin);
Serial.println("Fresquete");
delay(2000);
}else if (temperatura >= 17 && temperatura < 23) {
digitalWrite(pinled1, HIGH);
digitalWrite(pinled0, LOW);
digitalWrite(pinled2, LOW);
noTone(buzz_pin);
Serial.println("haku porã");
delay(2000);
} else if (temperatura >= 23 && temperatura < 34) {
digitalWrite(pinled2, HIGH);
digitalWrite(pinled1, LOW);
digitalWrite(pinled0, LOW);
noTone(buzz_pin);
Serial.println("haku porã");
delay(2000);
} else {
tone(buzz_pin, 1000);
digitalWrite(pinled2, LOW);
digitalWrite(pinled1, LOW);
digitalWrite(pinled0, LOW);
delay(2000);
}
}