#include
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
To control the LCD I used the LiquidCrystal library. The LiquidCrystal library comes with many built-in functions and makes controlling character LCDs super easy.
In the setup() the LCD is initiated with the function begin(cols,rows). When using a 20×4 LCD change this line to lcd.begin(20,4);
void setup() {
lcd.begin(16, 2);
lcd.print("DOAA fab Academy, 2020!");
}
void loop() {
lcd.display();
delay(500);
lcd.noDisplay();
delay(500);
}
#include
#include
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
dht DHT;
#define DHT11_PIN 7
The sketch starts by including LCD library and DHT library and defining the Arduino pin number to which our sensor’s Out pin is connected. Then we create a DHT object to access special functions related to the library.
void loop()
{
int chk = DHT.read11(DHT11_PIN);
lcd.setCursor(0,0);
lcd.print("Temp: ");
lcd.print(DHT.temperature);
lcd.print((char)223);
lcd.print("C");
lcd.setCursor(0,1);
lcd.print("Humidity: ");
lcd.print(DHT.humidity);
lcd.print("%");
delay(1000);
}
The Arduino will print the temperature and relative humidity values on the 16×2 character LCD. By using the input varibals coming from the sensor signal pin to the LCD, it will write the temperature dgree and humidity persntage.