Hello!
I'm a newbie to Arduino and therefore my code might be entirely wrong or my mistake too stupid. Please help me!
With the below code, the LCD display doesn't seem to be changing the point where text is displayed from on the screen and all the text churns out as one line, pushing the rest away until the entire screen is filled with text.
#include <LiquidCrystal.h>
#include <DHT.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
#define DHTPIN 6
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
void setup() {
lcd.begin(16, 2);
dht.begin();
}
void loop() {
float h = dht.readHumidity();
float t = dht.readTemperature();
float f = dht.readTemperature(true);
float hif = dht.computeHeatIndex(f, h);
float hic = dht.computeHeatIndex(t, h, false);
lcd.clear();
lcd.setCursor(0, 2);
lcd.print("Humid: ");
lcd.print(h, DEC);
lcd.print("%");
lcd.setCursor(0, 1);
lcd.print("Temp: ");
lcd.print(t, DEC);
lcd.print("C");
delay(1000);
lcd.clear();
lcd.setCursor(0, 2);
lcd.print("Heat Index");
lcd.setCursor(0, 1);
lcd.print("HI: ");
lcd.print(hic, DEC);
lcd.print("C");
delay(500);
lcd.setCursor(0, 2);
lcd.print("Taking reading!");
//DHT needs 2 seconds to read
//2000/10 = 200
//Add some animations for aesthetic
lcd.setCursor(0, 1);
//16 chars
//[x/xx]..........
lcd.print("[0/10]");
delay(200);
lcd.print("[1/10].");
delay(200);
lcd.print("[2/10]..");
delay(200);
lcd.print("[3/10]...");
delay(200);
lcd.print("[4/10]....");
delay(200);
lcd.print("[5/10].....");
delay(200);
lcd.print("[6/10]......");
delay(200);
lcd.print("[7/10].......");
delay(200);
lcd.print("[8/10]........");
delay(200);
lcd.print("[9/10].........");
delay(200);
lcd.print("[10/10]..........");
}
How do I fix it so that the text doesn't display incorrectly?
Thanks!
P.S The readings from the sensor are displayed as long, unrounded values with lots of decimal places. Anyway to fix this? (This is one of my stupid mistakes that I'm not sure how to fix)