Hi,
this is all new, so apologies for such a simple answer. I've been running through the inbuilt projects, just trying to get familiar with it all.
I'm using a project from online, which I'm trying to modify. Again, just to get used to the language etc
For some reason I can not figure out how to get the LCD display to show one decimal place, so then I can adjust the limits for the LEDs. For example, how do I get it do display 21.9?
Do I have to insert an int function?
Thank you
P.S.
The code is attached, rather than pasting
P.P.S.
I’ve just read how to insert the code properly but I’m on the mobile now and currently unable to edit the post. Thank you.
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
DHT dht(DHTPIN, DHTTYPE);
void setup()
{
Serial.begin(9600);
for (int DigitalPin = 7; DigitalPin <= 9; DigitalPin++)
{
pinMode(DigitalPin, OUTPUT);
}
lcd.begin(16,2); //16 by 2 character display
dht.begin();
}
void loop()
{
delay(1000);
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
float h = dht.readHumidity();
// Read temperature as Celsius (the default)
float t = dht.readTemperature();
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Temp: ");
//lcd.print(t);
lcd.print(t,1);
lcd.print("'C");
lcd.setCursor(0,1);
lcd.print("Humid: ");
//lcd.print(h);
lcd.print(h,1);
lcd.print("%");
if (t<=21)
{
digitalWrite(7, HIGH);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
}
else if (t>=21)
{
digitalWrite(8, HIGH);
digitalWrite(7, LOW);
digitalWrite(9, LOW);
}
else if (t>=24)
{
digitalWrite(9, HIGH);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
}
}
temp and humidity sensor.txt (1.27 KB)