code error

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

void setup() {
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("Temp:  Humidity:");

void loop() {
  // 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)) {


sketch_aug26b:15: error: expected constructor, destructor, or type conversion before ‘(’ token



C:\Users\user\Documents\Arduino\sketch_aug26b\sketch_aug26b.ino: In function ‘void setup()’:

sketch_aug26b:20: error: expected unqualified-id before ‘.’ token



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

You run the DHT () function out of the main functions (setup or loop). That is not allowed. Put it in the setup instead.

Please post a link to where you downloaded the DHTlib library.

Thanks for using code tags for your sketch! Please also do so when you post error/warning messages or other console output on the forum. This will ensure that it is properly formatted and make it easy for us to read.

shelbykate19: DHT (DHTPIN, DHTTYPE);

This is wrong: you've written it as if it were a function. It's not, it's a class. You need to create an instance of that class: