Hi i know a little bit of code i wrote some of this i copied some form the internet here is my code i get some errors that i cant fix
Than you!!``Preformatted text`
[code]
// Temp/Humidity Sensor
#include "DHT.h"
// LCD
#include <Wire.h>
#include <Adafruit_RGBLCDShield.h>
// Temp/Humidity Sensor
#define DHTPIN 7 // what pin we're connected to
#define DHTTYPE DHT22 // DHT 22 (AM2302)
// Initialize DHT sensor for normal 16mhz Arduino
DHT dht(DHTPIN, DHTTYPE);
// LCD
Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();
// Relay
#define RELAYPIN 10
// setup the Tempt/Humidity Sensor
dht.begin();
// Setup relay
pinMode(RELAYPIN, OUTPUT);
}
void loop() {
// Wait a few seconds between measurements.
delay(2000);
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
float humidity = dht.readHumidity();
// Read temperature as Fahrenheit
float temp = dht.readTemperature(true);
// Check if any reads failed and exit early (to try again).
if (isnan(humidity) || isnan(temp)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
if (temp < 100) {
digitalWrite(RELAYPIN, HIGH);
} else if (temp > 101) {
digitalWrite(RELAYPIN, LOW);
}
#include <Servo.h>
SERVO SERVO ;
int degrees ;
boolean button_state_1 ;
void setup () {
SERVO . attach ( 9 );
pinMode ( 2 , INPUT );
}
if ( millis () / 1000 < 1555200 ) {
for ( degrees = 90 ; degrees <= 135 ; degrees += 9 ) {
SERVO . write ( degrees );
delay ( 2000 );
}
delay ( 8000 ); for ( degrees = 135 ; degrees >= 90 ; degrees -= 9
) {
SERVO . write ( degrees );
delay ( 2000 );
} for ( degrees = 90 ; degrees >= 45 ; degrees -= 9 ) {
SERVO . write ( degrees );
delay ( 2000 );
}
delay ( 8000 ); for ( degrees = 45 ; degrees <=
90 ; degrees += 9 ) {
SERVO . write ( degrees );
delay ( 2000 );
}
} else {
SERVO . write ( 90 );
}
button_state_1 = digitalRead ( 2 ); if ( button_state_1 == HIGH ) {
}
}
lcd.setCursor(0, 0);
[/code]
````Preformatted text`
THIS IS THE ERROR MESSAGE
Arduino: 1.8.19 (Windows Store 1.8.57.0) (Windows 10), Board: "Arduino Uno"
sketch_mar02b:21:3: error: 'dht' does not name a type
dht.begin();
^~~
sketch_mar02b:24:10: error: expected constructor, destructor, or type conversion before '(' token
pinMode(RELAYPIN, OUTPUT);
^
sketch_mar02b:25:1: error: expected declaration before '}' token
}
^
exit status 1
'dht' does not name a type
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.Preformatted text
I coppied a part from github and deleted the lines that used components i dont need. I know that this is not the best way but i kept getting errors on lines for components i dont need
hi
i read it before making this post that is why i said i know a little bit of code i posted all my code as well as my error message like it states on the post. As for formating i tried to format in the ide before pasting here an i also tried to format here it seems that the part of code i wrote does not get formated.
Thank you!
hi
Could you be a bit more specific as to what lines are concatenated together or broken in mid-statement. As you can see i deleted the second loop() but other than that i dont know how to fix the rest of the things that you mention
i dont know if you can tell but the part about the servo i 'wrote' it my self i used blocky arduino since i am in the process of learning code. My original thought was to have a very early staged code with that whould be the basic concept just to see how my hardware is working and then change the code little by little until i get to the desired result
hi
thank you for fixing it and correctly formatting it
My question is what library is (# include "sim.hh") and is its function?
I tried the web but came up empty handed