Incubator code not working

I connected an Arduino uno clone with a DHT11, Liquid Crystal 12c, and a servo tower pro-SG92R to make an incubator that tracks the temperature and humidity and rolls
the eggs. I tried the code out, and everything went well except for the servo. Can you guys tell me what could be the problem? Can't attach hardware photo because I'm a new user

#include <DHT.h>
#include <LiquidCrystal_I2C.h>
#include <Servo.h>

#define DHTPIN 2            // Digital pin connected to the DHT sensor
#define DHTTYPE DHT11       // DHT 11
#define VCC2  12 // define pin 5 or any other digital pin here as VCC2
#define GND2  13 // define pin 2 or any other digital pin as Ground 2

DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal_I2C lcd(0x27, 16, 2); // LCD
Servo eggRotator; // Servo motor object
int servoPin = 9; // Servo control pin
unsigned long rotationInterval = 24 * 60 * 60 * 1000; // Rotation interval: 24 hours

void setup() {
  // Robojax.com getting extra 5V pin from Arduino 20181202
  pinMode(VCC2, OUTPUT);//define a digital pin as output
  digitalWrite(VCC2, HIGH);// set the above pin as HIGH so it acts as 5V

  pinMode(GND2, OUTPUT);//define a digital pin as output
  digitalWrite(GND2, LOW);// set the above pin as LOW so it acts as Ground

  Serial.begin(9600);
  dht.begin();
  lcd.init();
  lcd.backlight();

  eggRotator.attach(servoPin); // Attaching servo motor to pin
}

void loop() {
  readTemperatureAndHumidity();
  rotateEgg();
  delay(rotationInterval);
}

void readTemperatureAndHumidity() {
  float humidity = dht.readHumidity();
  float temperature = dht.readTemperature();

  if (isnan(humidity) || isnan(temperature)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }

  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Temp: ");
  lcd.print(temperature);
  lcd.print(" C");

  lcd.setCursor(0, 1);
  lcd.print("Humidity: ");
  lcd.print(humidity);
  lcd.print("%");

  Serial.print("Temperature: ");
  Serial.print(temperature);
  Serial.print("°C. Humidity: ");
  Serial.print(humidity);
  Serial.println("%");
}

void rotateEgg() {
  // Rotate the egg 90 degrees clockwise
  eggRotator.write(180);
  delay(1.44e+7);
  // Return to initial position
  eggRotator.write(0);
  delay(1.44e+7);
  eggRotator.write(180);
  delay(1.44e+7);
  eggRotator.write(0);
  delay(4.32e+7);
}

Welcome to the forum

To post images etc. you need trust level 1, you can get there by:

  • Entering at least 5 topics
  • Reading at least 30 posts
  • Spend a total of 10 minutes reading posts

Users at trust level 1 can...

  • Use all core Discourse functions; all new user restrictions are removed
  • Send PMs
  • Upload images and attachments

Okay, thank you!

A schematic of your project would almost certainly better than any 'photo

What problem are you having?
Describe as clearly as possible....

What power source are you using for the servo?

PS: What is this ????

1.44e+7 = 1.44 x 107 = 14,400,000

This is an incubator program I made as a project that can track the temperature and humidity(Can also roll eggs). I don't think there's a problem with the software, so I'm guessing as a hardware problem. The servo motor just doesn't move and only makes a small buzzing noise. Everything else works just fine

Servo issues are often due to insufficient power. Can you move the servo using one of the examples provided with the IDE?

Which example are you mentioning?

This delays has
1.44e+7 = 1.44 x 107 = 14,400,000 Ms

14,400,000 / 1000 / 60 = 240min

This delay takes 240 min. to go to next instruction,
so the servo is stopped every 240 min.

Try this simulated with delay of 1000 Ms ...

I tried only with the servo, and it worked fine. I think the power supply might be the problem. What could I do to add more power to the UNO?

Here is a simple simulation of what the actual thing looks like

But the sensor is a DHT11 instead of 22

Are you actually trying to power the servo from one of the digital pins of the UNO?????

That's what I was trying previously but I might connect a battery pack on if it can't

The servo needs an external power supply, not even the 5V pin of the UNO can supply enough current to run a servo.

Okay, thank you! Should I cut off the tip of the battery pack wire and plug it into the servo's VCC and GND?

You really need a better connection than just sticking a wire into the connector.
There does need to be a common ground between the servo power supply and the UNO.

Okay, thank you all for helping me!!

You do not add power to the Arduino-uno.

You add a extra power-supply this way

As user @david_2018 said

Okay thank you everybody!

I doubt that a DHT11 is good enough to measure the temperature of an incubator.
Use at least a (genuine/calibrated) DS18B20 for temperature.

Try to use millis() timing instead of blocking delay().
The BlinkWithoutDelay example in the IDE will show you how.
Leo..