I trying to use my DHT11 with a light sensor, that part is ok both of them are working well, but i dont know why my buttons are not working, I am trying to use one to control a relay but it take a very long time to change the state (normally 5~6 secs), is something wrong in my code?
//Libraries
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#include <IRremote.h>
#include <SimpleTimer.h>
#include <dht.h>
//Definiçoes
#define dht_dpin A1
//Pré void
dht DHT;
SimpleTimer timer;
IRsend irsend;
char auth[] = "e2a6bdbbd0a34bc7a1f6379e834fe88a";
void setup() {
Serial.begin(9600);
Blynk.begin(auth);
}
void loop() {
{
if (DHT.humidity > 95) {
Blynk.notify("Alto risco de chuva");
}
if (DHT.humidity < 30) {
Blynk.notify("Umidade do ar muito baixa");
}
int luz = analogRead(5);
luz = map(luz, 0, 1023, 0, 100);
int chk = DHT.read11(dht_dpin);
Blynk.virtualWrite(1, String(DHT.temperature) + "*C");
Blynk.virtualWrite(2, String(DHT.humidity) + "%");
Blynk.virtualWrite(3, String(luz) + "%");
delay(200);
Blynk.run();
}
BLYNK_WRITE(2)
{
if (param.asInt()){
irsend.sendNEC(0xC20DF, 32); // Source
delay(40);
}
}
BLYNK_WRITE(3)
{
if (param.asInt()){
irsend.sendNEC(0xCD02F, 32); // Up
delay(40);
}
}
BLYNK_WRITE(4)
{
if (param.asInt()){
irsend.sendNEC(0xC30CF, 32); // Down
delay(40);
}