i've been working on this code almost all day and i couldnt get the DHT11 sensor to work, nor my complete code, if someone can help me with this i would be amazing
my code is:
#include <dht11.h>
#define DHT11PIN 8
dht11 DHT11;
#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5,4,3,2);
int but=LOW;
void setup() {
pinMode (6,OUTPUT);
pinMode(9,OUTPUT);
pinMode(7,INPUT_PULLUP);
lcd.begin(16,2);
lcd.setCursor(1, 0);
lcd.print("Press button");
lcd.setCursor(3, 1);
lcd.print("to start");
}
void loop() {
lcd.clear();
delay(5000);
but= digitalRead(7);
lcd.setCursor(1, 0);
lcd.print("Press button");
lcd.setCursor(3, 1);
lcd.print("to start");
noTone(9);
while(but=HIGH){
noTone(9);
lcd.setCursor(3,0);
lcd.print("Loading...");
delay(5000);
digitalWrite(6,HIGH);
delay(5000);
digitalWrite(6,LOW);
delay(5000);
tone (9, 600, 2000);
lcd.clear();
int tmp = DHT11.read(DHT11PIN);
if (tmp <= 10); {
lcd.setCursor(0,1);
lcd.print("Temp:");
lcd.print((float)DHT11.temperature,2);
lcd.print(" C");
lcd.setCursor(0,0);
lcd.print("Go with jacket");
delay(5000);
lcd.clear();
}
if (10< tmp <=20); {
lcd.setCursor(0,1);
lcd.print("Temp:");
lcd.print((float)DHT11.temperature,2);
lcd.print(" C");
lcd.setCursor(0,0);
lcd.print("Go with sweater");
delay(5000);
lcd.clear();
}
if (20< tmp <=30); {
lcd.setCursor(0,1);
lcd.print("Temp:");
lcd.print((float)DHT11.temperature,2);
lcd.print(" C");
lcd.setCursor(0,0);
lcd.print("Go whith pants");
delay(5000);
lcd.clear();
}
if (30< tmp <=40); {
lcd.setCursor(0,1);
lcd.print("Temp:");
lcd.print((float)DHT11.temperature,2);
lcd.print(" C");
lcd.setCursor(0,0);
lcd.print("Go with shorts");
delay(5000);
lcd.clear();
}
if (40< tmp <=50); {
lcd.setCursor(0,1);
lcd.print("Temp:");
lcd.print((float)DHT11.temperature,2);
lcd.print(" C");
lcd.setCursor(0,0);
lcd.print("don't go out");
delay(5000);
lcd.clear();
}
}
}