From 8bd54f6e73bb78d2b4980de9fb7baebc5d6b5699 Mon Sep 17 00:00:00 2001 From: Roald Batts Date: Wed, 28 Dec 2022 22:25:00 -0500 Subject: [PATCH] Got dht working. --- soler_chager.ino | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/soler_chager.ino b/soler_chager.ino index 2825473..3d7dfe1 100644 --- a/soler_chager.ino +++ b/soler_chager.ino @@ -1,12 +1,14 @@ #include #include -#include +#include + #define DHT11_PIN 7 #define photos A0 #define LED 3 #define button 2 #define buzzer 6 +DHT dht(DHT11_PIN, DHT11); volatile int buttonState; volatile int value = 0; int count; @@ -26,6 +28,9 @@ void setup() lcd.printstr("Hello, World!"); lcd.setCursor(0,1); lcd.printstr("hello, Roald!"); + + dht.begin(); + Serial.print("done setting up!\n"); } @@ -35,25 +40,18 @@ void loop()// the loop function runs over and over again forever Serial.print(count); Serial.print("] hey\n"); - int chk; - chk = DHT.read(DHT11_PIN); - switch (chk) { - case DHTLIB_OK: - break; - case DHTLIB_ERROR_CHECKSUM: - break; - case DHTLIB_ERROR_TIMEOUT: - break; - default: - break; - } + float hum; + float temp; + temp = dht.readTemperature(); + hum = dht.readHumidity(); { - Serial.print("humidity:"); - Serial.print(DHT.humidity); - Serial.print(" temperature:"); - Serial.println)DHT.temperature); - delay(200); + Serial.print("humidity:"); + Serial.print(hum); + Serial.print(" temperature:"); + Serial.println(temp); + delay(200); } + value = analogRead(photos); Serial.println(value); if (value > 300){ @@ -66,7 +64,6 @@ void loop()// the loop function runs over and over again forever //blink(); - buttonState = digitalRead(button); if(buttonState == 0) { digitalWrite(LED, HIGH); @@ -76,9 +73,8 @@ void loop()// the loop function runs over and over again forever } delay(100); - count++; - +} void birthdaySong() { tone(buzzer, 294);