0% found this document useful (0 votes)
2 views2 pages

Paneda

The document outlines a C++ program for interfacing a microcontroller with a DHT sensor and displaying the readings on an LCD. It includes initialization of the sensor and LCD, as well as a loop to continuously read and display humidity and temperature data. The code is structured to clear the LCD and update the displayed values every two seconds.

Uploaded by

Danielle Paneda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Paneda

The document outlines a C++ program for interfacing a microcontroller with a DHT sensor and displaying the readings on an LCD. It includes initialization of the sensor and LCD, as well as a loop to continuously read and display humidity and temperature data. The code is structured to clear the LCD and update the displayed values every two seconds.

Uploaded by

Danielle Paneda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

PANEDA, DANIELLE MARIE A.

AUGUST 4, 2025
EMBEDDED SYSTEMS BSCPE 41A1

Instruction: Create or write a program (C++ or any application software) to interface a


microcontroller with a sensor and display the sensor reading on an LCD. The program should
include initialization of microcontroller and sensor, reading data from the sensor, and displaying
the data on an LCD.

#include "DHT.h"
#define DHTPIN 4// you can use
#define DHTTYPE DHT11//#define DHTTYPE DHT21
//#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);//you can also use pins 3, 4, 5, 12, 13 or 14
// Pin 15 can work but DHT must be disconnected during program upload
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
dht.begin();// initialize the sensor
lcd.backlight();// turn on lcd backlight
lcd.init();// initialize lcd
}
void loop() {
lcd.clear();
lcd.setCursor(0,0);// set the cursor on the first row and column
lcd.print("Humidity=");
lcd.print((float)dht.readHumidity());//print the humidity
lcd.print("%");
lcd.setCursor(0,1);//set the cursor on the second row and first column
lcd.print("Temp=");
lcd.print((float)dht.readTemperature());//print the temperature
lcd.print("Celsius");
delay(2000);
lcd.clear();
}
Output:

You might also like