#include <DHT11.h>
#define DHTPIN A0
#define DHTTYPE DHT11
DHT11 dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin (9600);
pinMode(8, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(A1, INPUT);
}
void loop() {
delay(2000);
int t = dht.readTemperature();
Serial.print("Temperature: ");
Serial.print(t);
Serial.print(" C");
if(t>=33.0) {
analogWrite(5,255);
analogWrite(6,0);
digitalWrite(8,0);
}
else {
digitalWrite(8,0);
analogWrite(5,0);
analogWrite(6,0);
}
}
at
Arduino:1.8.16 (Windows 10), board:"Arduino Uno"
sketch_may22a:4:26: error: expected primary-expression before ')' token
C:\Users\써니쁘니\Desktop\sketch_may22a\sketch_may22a.ino: In function 'void loop()':
sketch_may22a:17:15: error: 'class DHT11' has no member named 'readTemperature'
exit status 1
expected primary-expression before ')' token
This report shows "Show detailed output during compilation" in the file -> preferences Enable more information You can make it visible.
That's the error code, but I don't know how to solve it
arduino
sketch_may22a:4:26
There was a problem near the 26th letter of the 4th line.
The fourth line says DHT11 dht (DHTPIN, DHTTYPE);
.
The 26th letter here is ')', which tells us that we need a primary-expression before this.
I don't think I'm telling you the exact question, and I don't know what it means, but the grammar in line 4 seems to be wrong.
The void loop function reportedly experienced a problem.
It says sketch_may22a:17:15 right?
If you look at the 15th letter of the 17th line,
int t = dht.readTemperature();
points to the first letter r of readTemperature. There's a problem here, so let's look at the next phrase.
'class DHT11' has no member named 'readTemperature'
The DHT11 class says there is no member named readTemperature
int t = dht.readTemperature();
That's where the problem.
dht says there is no readTemperature method.
There is a possibility that the problem occurred one after another due to the previous problem. I think it would be good to solve the previous problem first.
© 2024 OneMinuteCode. All rights reserved.