i want to designee auto roofing system

Hi everyone

I got a problem designing of auto roofing system my goal is to you open the roof if temperature is high and rain is high no rain and temperature is low roof will close but I am unable to do the output and iam sharing the code can you help me to correct the code thank you

#include <dht.h>

dht DHT;

#define DHT11_PIN A1

int ldr=A2;

void setup() {
Serial.begin(9600);
pinMode(A0, INPUT);
pinMode(12,OUTPUT);
pinMode(11,OUTPUT);
pinMode(10,OUTPUT);
}

void loop()
{

analogWrite(10,155);
int sensorVal = digitalRead(A0);

int chk = DHT.read11(DHT11_PIN);
Serial.print("Temperature = ");
Serial.println(DHT.temperature);
Serial.print("Humidity = ");
Serial.println(DHT.humidity);

if (sensorVal==1 || DHT.temperature<=34)
{
digitalWrite(12,HIGH);
digitalWrite(11,LOW);
delay(5000);
digitalWrite(12,LOW);
digitalWrite(11,LOW);

while(digitalRead(A0)==1);
while(DHT.temperature<=34);
}

if(sensorVal==0 || DHT.temperature>=35)
{
digitalWrite(11,HIGH);
digitalWrite(12,LOW);
delay(5000);
digitalWrite(12,LOW);
digitalWrite(11,LOW);

while(digitalRead(A0)==0);
while(DHT.temperature>=35);
}

}

while(DHT.temperature>=35);Do you see a problem here if the last measured temperature was >= 35?

please read How To Use This Forum

it is a sticky post at the top of every forum.

#7 explains how to post code.
the bottom right of your post is where you find the modify button.

And don't cross-post.

You already had an answer on this topic when you duplicated.

Duplicate deleted.

I have to admit that I cannot follow your project.

I would ask that you label your work

#include <dht.h>
dht DHT;
#define DHT11_PIN A1  
int ldr=A2;                              // light sensor 

void setup() {
 Serial.begin(9600);
 pinMode(A0, INPUT);   // a digital input on an analog pin connected to the __________-
 pinMode(12,OUTPUT);  //  output for ______________
 pinMode(11,OUTPUT);  // output for _______________
 pinMode(10,OUTPUT);  //   pwm out fixed at 155
}

also, it seems you only look at the DHT so all information is based on temperature.

could you write out your intention ?

read the DHT temperature
if the temperature is over 35, then drive motor on pin11 to open the roof for 5 seconds, then close
if the temperature is under 34, then drive the motor on pin12 to close the roof for 5 seconds then open
send pin 10 an analog value to 155 to send PWM out

In my view, when you write out the things you want to do, then arrange them in the order you think, then your thinking and programming will flow better.

Also, since it sounds like you want to drive the roof closed if it is cold or if it is raining, then you could put your outputs at the end.

Read temperature sensor
Read rain sensor

if it is hot, set the Motor_Value to ‘open’
if it is cold, the the Motor_Value to ‘closed’
if it is raining, set the Motor_Value to ‘closed’

output motor to ‘Motor_Value’

instead of trying to drive the motor in the middle of the program, set the condition you want for the motor
after all your logic, at the end of the sketch, you drive the motor.