I am working on automating a humidifier from the arduino projects site. The code given seems to have an error. Can anyone help me fix it? (I'm no good at programming.)
#include <dht.h>
#include <LiquidCrystal.h>
// include the library code:
#include <LiquidCrystal.h>
#include "DHT.h"
// set the DHT Pin
#define DHTPIN 8
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
#define DHTTYPE DHT11
DHT (DHTPIN, DHTTYPE);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
dht.begin();
// Print a message to the LCD.
lcd.print("Temp: Humidity:");
}
void loop() {
delay(500);
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// read humidity
float h = dht.readHumidity();
//read temperature in Fahrenheit
float f = dht.readTemperature(true);
if (isnan(h) || isnan(f)) {
lcd.print("ERROR");
return;
}
lcd.print(f);
lcd.setCursor(7,1);
lcd.print(h);
}
sketch_aug26b:15: error: expected constructor, destructor, or type conversion before '(' token
DHT (DHTPIN, DHTTYPE);
^
C:\Users\user\Documents\Arduino\sketch_aug26b\sketch_aug26b.ino: In function 'void setup()':
sketch_aug26b:20: error: expected unqualified-id before '.' token
dht.begin();
^
C:\Users\user\Documents\Arduino\sketch_aug26b\sketch_aug26b.ino: In function 'void loop()':
sketch_aug26b:32: error: expected primary-expression before '.' token
float h = dht.readHumidity();
^
sketch_aug26b:34: error: expected primary-expression before '.' token
float f = dht.readTemperature(true);
^
Using library DHTLib in folder: C:\Users\user\Documents\Arduino\libraries\DHTLib (legacy)
Using library LiquidCrystal at version 1.0.5 in folder: C:\Users\user\Downloads\arduino-1.6.10-windows (1)\arduino-1.6.10\libraries\LiquidCrystal
exit status 1
expected constructor, destructor, or type conversion before '(' token