Control Servo Motor with DHT11

Hello!
I want to control my servo motor with my DHT11 for an art project. When my sensor humidity is at 95%, i want that my motor make a 180° rotation then stop, then return at his initial position after 20 sec.

This my code (but it didn't work). Can someone help me? :confused:

#include "DHT.h"

#include <Servo.h>

#define DHTPIN A0

#define DHTTYPE DHT11

DHT dht(DHTPIN, DHTTYPE);

Servo myservo; // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0; // variable to store the servo position
float h = 0;
int sure;

void setup() {
// put your setup code here, to run once:;
myservo.attach(9); //We introduced the ninth pin arduino to the servo motor
dht.begin();
Serial.begin(9600);
}

void loop() {

myservo.write(0);
Serial.begin(9600);

sure = pulseIn(A0, HIGH);
h = (A0/29.1)/2;

// put your main code here, to run repeatedly:
float h = dht.readHumidity();

Serial.print("Humidity: ");
Serial.print(h);
Serial.println();
delay(1000);

if (h > 95) {
myservo.write(180);
delay(20000);
}

That code doesn't even compile so it's obviously not going to work.

In loop() why are you setting a value in variable h (by dividing a pin number by 29.1) and then immediately creating a brand new variable with the same name and setting that from dht.readHumidity()? Which one do you expect would be used in your if statement?

Steve