Untitled
unknown
python
2 years ago
1.3 kB
3
Indexable
#include <DHT.h> #include <LiquidCrystal.h> #define DHTPIN 53 // Digital pin connected to the DHT11 data pin #define DHTTYPE DHT11 // DHT sensor type // initialize the library by associating any needed LCD interface pin // with the arduino pin number it is connected to const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; LiquidCrystal lcd(rs, en, d4, d5, d6, d7); DHT dht(DHTPIN, DHTTYPE); void setup() { pinMode(53, INPUT); Serial.begin(9600); // set up the LCD's number of columns and rows: lcd.begin(16, 2); // Print a message to the LCD. // Serial.println("hello, world!"); dht.begin(); } void loop() { delay(2000); // Wait for 2 seconds between readings lcd.setCursor(0, 0); float humidity = dht.readHumidity(); float temperature = dht.readTemperature(); // Check if any reads failed and exit early if (isnan(humidity) || isnan(temperature)) { Serial.println("Failed to read from DHT sensor!"); } Serial.print("Humidity:"); Serial.print((int)humidity); Serial.print("|"); Serial.print("Temperature:"); Serial.print((int)temperature); lcd.print(String("Temp: ")); lcd.print((int)temperature); lcd.print(" st. C"); lcd.setCursor(0, 1); lcd.print(String("Wilg: ")); lcd.print((int)humidity); lcd.print(" %"); delay(1000); }
Editor is loading...