code error
i working on automating humidifier arduino projects site. code given seems have error. can me fix it? (i'm no @ programming.)
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 @ 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
code: [select]
#include <dht.h>
#include <liquidcrystal.h>
// include library code:
#include <liquidcrystal.h>
#include "dht.h"
// set dht pin
#define dhtpin 8
// initialize library numbers of interface pins
liquidcrystal lcd(12, 11, 5, 4, 3, 2);
#define dhttype dht11
dht (dhtpin, dhttype);
void setup() {
// set lcd's number of columns , rows:
lcd.begin(16, 2);
dht.begin();
// print message lcd.
lcd.print("temp: humidity:");
}
void loop() {
delay(500);
// set cursor column 0, line 1
// (note: line 1 second row, since counting begins 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 @ 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 dht () function out of main functions (setup or loop). not allowed. put in setup instead.
Arduino Forum > Topics > Home Automation and Networked Objects > code error
arduino
Comments
Post a Comment