im having a problem with my code i dont know how to fix it because im still an amateur at arduino coding and i have been tasked in making a code using a dht library and a liquid crystal library and mix them up so that a measurement shows on the lcd screen but i have been on this for over a week and i cant seem to find the error can someone pls help me
this is my last code i made
#include <LiquidCrystal.h>
#include <DHT.h>
#include <DHT_U.h>
#include <Adafruit_Sensor.h>
LiquidCrystal.h lcd(0x3F, 16, 2);
DHT dht;
const int DHT11_PIN = 4;
void setup()
{
lcd.begin();
lcd.backlight();
}
void loop()
{
dht.read11(DHT_PIN);
lcd.setCursor(0, 0);
lcd.print("Temp: ");
lcd.print(dht.temperature, 0);
lcd.print(char(223));
lcd.print("C");
lcd.setCursor(0, 1);
lcd.print("Humidity: ");
lcd.print(dht.humidity, 0); lcd.print(" %");
delay(200);
}
using a liquid crystal by 2006-2008 Hans-Christoph Steiner
a dht by adafruit
and this was my first one using the same libraries
#include <LiquidCrystal.h>
#include <DHT.h>
#include <DHT_U.h>
#include <Adafruit_Sensor.h>
DHT dht11(6);
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
char message[] = dht11.readTemperatureHumidity;
int messageLength;
int scrollPosition = 0;
void setup() {
lcd.begin(16, 2);
lcd.print( dht11.readTemperatureHumidity);
messageLength = strlen(message);
delay(1000);
Serial.begin(9600);
}
void loop() {
lcd.clear();
for (int i = 0; i < 16; i++) {
int charIndex = scrollPosition + i;
if (charIndex >= messageLength) {
charIndex -= messageLength;
}
lcd.setCursor(i, 0);
lcd.print(message[charIndex]);
}
scrollPosition++;
if (scrollPosition >= messageLength) {
scrollPosition = 0;
}
delay(300);
int temperature = 0;
int humidity = 0;
int result = dht11.readTemperatureHumidity(temperature, humidity);
if (result == 0) {
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.print(" °C\tHumidity: ");
Serial.print(humidity);
Serial.println(" %");
} else {
Serial.println(DHT11::getErrorString(result));
}
}
i would really appreciate the help