Connecting problem to servo +moisture+ir sensor

I m creating one project and in that I m using moisture sensor+ir sensor+servo motor.
I need help regarding code like I want to control servo motor with moisture sensor ,if any dry object will come in contact with moisture sensor then ir sensor have to detect it and rotate the sevo motor left and if any wet object will come in contact with moisture sensor then ir sensor have to detect it and rotate the servo motor right side. I wrote one code but in that code my servo motor is rotating only right side when any wet object is coming in contact.so plz… help me for modifying the code Or plz…send the correct code so that it will work for both condition left(dry) and right (wet)

<
#include <Servo.h>

class Smart_Segregator
{
public:
int servo_pin=6;
int moisture_sensor_pin=A0; // connect to the analog pin A0 of the nodemcu
int ir_sensor_pin=5;
int detect_moisture;
int detect_ir;

 Servo servo;

 Smart_Segregator(int pin_1, int pin_2, int pin_3)
 {
   servo_pin = 6;
   moisture_sensor_pin = A0;
   ir_sensor_pin = 5;

   detect_moisture = 1;
   detect_ir = true;
 }

void init()
{
  Serial.begin(9600);
  servo.attach(6);
  servo.write(90);
  
  pinMode(moisture_sensor_pin, INPUT);
  pinMode(ir_sensor_pin, INPUT);

  Serial.println("segration is raedy");
}

void dry_waste()
{
  servo.write(0);
}

void wet_waste()
{
  servo.write(180);
}

void neutral_state()
{
  servo.write(90);
}

void execute()
{
  detect_moisture = analogRead(moisture_sensor_pin);
  detect_ir = digitalRead(ir_sensor_pin);

  if (detect_moisture <=1023 && detect_ir == false)
  {
    wet_waste();
  }

  else if (detect_moisture ==0 && detect_ir == true)
  {
    dry_waste();
  }

  else 
  {
    neutral_state();
  }
}

}

segregator = Smart_Segregator(6,A0,5);

void setup()
{
segregator.init();
}

void loop()
{
segregator.execute();
}

@

Your other topic on the same subject deleted.

Please do not duplicate your questions as doing so wastes the time and effort of the volunteers trying to help you as they are then answering the same thing in different places.

Please create one topic only for your question and choose the forum category carefully. If you have multiple questions about the same project then please ask your questions in the one topic as the answers to one question provide useful context for the others, and also you won’t have to keep explaining your project repeatedly.

Repeated duplicate posting could result in a temporary or permanent ban from the forum.

Could you take a few moments to Learn How To Use The Forum

It will help you get the best out of the forum in the future.

Thank you.

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

help me for code

Start by posting your code correctly

Start by using available example code for each device in order to learn and manage them. Don't even dream of a complete project coming from forum. You will make the project, not forum.