0
votes

Here I include my library:

#include <LiquidCrystal.h>
#include <SimpleDHT.h>
LiquidCrystal LCD();
SimpleDHT11 dht11();

I declare my ints and pins:

 int pinDHT11 = 12;
 int temperature;
 int humidity;
 int GLED = 13;
 int RLED = 8;.

I make my void setup:

 void setup() {
 Serial.begin(9600);
 pinMode (GLED, OUTPUT);
 pinMode (RLED, OUTPUT); 
 LCD.begin (16,2);
}

I make my void loop:

void loop() {

Serial.println("Sensor");

// read with raw sample data.
byte temperature = 0;
byte humidity = 0;
if (dht11.read(pinDHT11, &temperature, &humidity, NULL)) {
Serial.print("Read DHT11 failed");
delay (1000);
return;
}

Serial.print("Temperatura: ");
Serial.print((int)temperature); Serial.println(" *C, ");
Serial.print ("Humedad");
Serial.print((int)humidity); Serial.println(" %");

LCD.setCursor (0,0);
LCD.print ("Temperatura"); LCD.print (temperature); LCD.print(" C");
LCD.setCursor (0,1);
LCD.print ("Humedad"); LCD.print (humidity); LCD.print(" %");
delay(1000);
}

And it gives me this error:

((DHT11:16: error: request for member 'begin' in 'LCD', which is of non-class type 'LiquidCrystal()'))

2

2 Answers

0
votes

In C++, LiquidCrystal LCD(); is interpreted as a function declaration.

Instead, use LiquidCrystal LCD; to invoke an empty constructor.

But from LiquidCrystal doc, there is no empty constructor available. Use one of the following :

LiquidCrystal(rs, enable, d4, d5, d6, d7) 
LiquidCrystal(rs, rw, enable, d4, d5, d6, d7) 
LiquidCrystal(rs, enable, d0, d1, d2, d3, d4, d5, d6, d7) 
LiquidCrystal(rs, rw, enable, d0, d1, d2, d3, d4, d5, d6, d7)
0
votes

On third line of your code, you are missing the pins used to connect LCD to Arduino board. It should be something like:

LiquidCrystal LCD(12, 11, 10, 5, 4, 3, 2);

If you're using pins 12, 11, 10, 5, 4, 3, 2 to wire up LCD to Arduino. Check every info you need on Liquid Crystal reference page.