Im a begginer coder in arduino so take it easy on me
So why does my buttons have a huge delay or dont even work when i press them ( ive tested in button testing codes and they work fine, no delay.)
#include <DHT2pin.h>
#include <DHT.h>
#define DHTPIN A2
#define DHTTYPE DHT11
#define BUTTON_UP_PIN 6
#define BUTTON_DOWN_PIN 7
DHT dht(DHTPIN, DHTTYPE);
int humidityThreshold = 60;
void setup() {
Serial.begin(9600);
Serial.print("?G420");
pinMode(5, OUTPUT);
pinMode(BUTTON_UP_PIN, INPUT_PULLUP);
pinMode(BUTTON_DOWN_PIN, INPUT_PULLUP);
dht.begin();
}
void loop() {
if (digitalRead(BUTTON_UP_PIN) == LOW) {
humidityThreshold += 1;
}
if (digitalRead(BUTTON_DOWN_PIN) == LOW) {
humidityThreshold -= 1;
}
digitalWrite(5, HIGH);
delay(1000);
digitalWrite(5, LOW);
delay(1000);
int delay_ms = 2000;
delay(delay_ms);
float temperature = dht.readTemperature();
float humidity = dht.readHumidity();
if (isnan(temperature) || isnan(humidity)) {
Serial.println("Falha ao ler o sensor DHT!");
return;
}
Serial.print("?f");
Serial.print("Temperatura = ");
Serial.print(int(temperature));
Serial.print(" Humidade = ");
Serial.print(int(humidity));
Serial.print(" Humidade Ideal: ");
Serial.print(humidityThreshold);
Serial.println("%");
delay(100);
}
Im using this lcd if its of any help New Product: SMD LCD 117 – Modern Device