// LCD1602 to Arduino Uno connection example
#include "DHT.h"
#include <LiquidCrystal.h>
#define DHTPIN 3
#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
void setup() {
lcd.begin(16, 2);
// you can now interact with the LCD, e.g.:
lcd.print("Hello World!");
dht.begin();
lcd.clear();
}
void loop() {
float temperature = dht.readTemperature();
float humidity = dht.readHumidity();
// Check if any reads failed and exit early (to try again).
if (isnan(temperature) || isnan(humidity)) {
lcd.println(F("Failed to read from DHT sensor!"));
return;
}
lcd.setCursor(0,0);
lcd.print("suhu :" + String(temperature));
lcd.setCursor(0,1);
lcd.print("humidity :" + String(humidity));
//Serial.print(F("Humidity: "));
//Serial.print(humidity);
//Serial.print(F("% Temperature: "));
// ...
}