programing problem

hi guys i started making a full automatic egg incubator i use a dht11 temperature and humidity sensor
for temperature everything are ok i will send a photo about the program i wrote and scematic
but i have a problem with humidity
i need to make a servo motor turn from 0 degree to 180 and return to 0 if the humidity level are less then 40% and i want it to repeat that until the humidity reach 40% , then the servo motor stop in 0 degree

please can anyone help me in programming that because i'm noob in arduino world thx

Note
the program in the photo work 100% i just need to add the servo motor part
the wiring in the schematic are not the same in the program

this is the code

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#include <dht.h>
#include <Servo.h>

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4,5, 6, 7, 3, POSITIVE);
dht DHT;

#define DHT11_PIN 7
int pinOut = 8;
Servo myservo;

void setup()
{
  lcd.begin(16, 2);
  Serial.begin(9600);
  pinMode(8, OUTPUT);
  myservo.attach(9);
}

void loop()
{
 
  int chk = DHT.read11(DHT11_PIN);
  lcd.setCursor(0,0); 
  lcd.print("Temp: ");
  lcd.print(DHT.temperature);
  lcd.print((char)223);
  lcd.print("C");
  lcd.setCursor(0,1);
  lcd.print("Humidity: ");
  lcd.print(DHT.humidity);
  lcd.print("%");
   delay(1000);
   if (DHT.temperature<=25){
    digitalWrite(pinOut, HIGH);
}
else {
    digitalWrite(pinOut, LOW);
  }
  delay(500);
  }

Post your code.

Why don't you post the code (within code tags) versus a picture we can't see...

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#include <dht.h>
#include <Servo.h>

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4,5, 6, 7, 3, POSITIVE);
dht DHT;

#define DHT11_PIN 7
int pinOut = 8;
Servo myservo;

void setup()
{
  lcd.begin(16, 2);
  Serial.begin(9600);
  pinMode(8, OUTPUT);
  myservo.attach(9);
}

void loop()
{
 
  int chk = DHT.read11(DHT11_PIN);
  lcd.setCursor(0,0); 
  lcd.print("Temp: ");
  lcd.print(DHT.temperature);
  lcd.print((char)223);
  lcd.print("C");
  lcd.setCursor(0,1);
  lcd.print("Humidity: ");
  lcd.print(DHT.humidity);
  lcd.print("%");
   delay(1000);
   if (DHT.temperature<=25){
    digitalWrite(pinOut, HIGH);
}
else {
    digitalWrite(pinOut, LOW);
  }
  delay(500);
  }

I just need to add the servo motor part

So where is your attempt? There are tons of on line egg incubator projects - did you check any?

J-M-L:
So where is your attempt? There are tons of on line egg incubator projects - did you check any?

i search for egg incubator projects but i didn't find anyone did it with arduino on youtube or in projects hub or in a web site (i mean controlling humidity not all the incubator)
so i wrote that code by collecting information from many places

first hit on Google...

Egg Incubator

Is an arduino controlled incubator for chicken's eggs. It's purpose is to keep temperature and humidity at defined values, so that the eggs are incubated and the chicks finally hatch after some days.

Does this help?

J-M-L:
first hit on Google...

Does this help?

i know that i just want to make a servo motor turn when the humidity level are less then 40% i need a code

if (DHT.humidity<40)
{

what i will wrote here that is the problem

}
read my topic again you will understand bro :slight_smile:

Ah - then it's the servo documentation you need? Look at the sweep example

video tutorial