Hey guys, need consultant, help

hello guys, im working on a little bit big project.
it contains about 5 servo motors, 4 relays, 4 stepper motors(3 nema23,1 nema17)with their drivers, ldr sensor,12voltlamp, dh11 sensor,12volt fan, 12volt water pump, 12 volt selonoid, ultra sonic, load sensor with HX module, ESP32, arduino mega.

im using external ANTEC power supply which is capable of giving high currents like 10A for 12 volt and around 6 or 8 for 5 Volt

i was building it module by module,every module was working just fine, but unfortuanetely i was using bread board which i know is my bad, but i need some expert advice, so when i merged the project all together, alot of noise occured and some of the modules works in a bad ways, like servo motors shake, stepper motor nema17(a4988 driver) shaking left and right, there are obvious noise or current problems.( note that the stepper motor drivers was powered directly from power supply, but still alot of noise.

i have several questions:
1- do u 10000% confirm that the breadboard is biggest part of the problem?
2- is the arduino mega capable of providing all the control signals for the modules, current wise i mean, im not using it as power supply btw.
3- what can i use to prevent shaking servo motors, stepper motors noise??
i provided the whole description, connections im sure 100% right, but i need help with the problems mentioned above and will be hugely appreciated.

Does your code have delays?
For one servo that will be fine, but if you have 4, the delay will increase by a factor 4...
You did not share your code...

#define LIGHT 22  // define pin 22 for sensor
#define RELAY 23  // define pin 23 for relay
#define DHTPIN 24
#define DHTTYPE DHT11  // DHT 11
#define FAN_SPEED 2
#define LASER 25
#define X 3
#define Y 4
#define food3 7
#define food2 8
#define food1 9
#define pinCleanServo 6
#define dirPin 26
#define stepPin 27
#define enPin 28
#define dirPin2 29
#define stepPin2 30
#define enPin2 31
#define dirPin3 32
#define stepPin3 33
#define enPin3 34
#define dirPin4 38
#define stepPin4 39
#define waterRelay 37
#define vacuumRelay 43
#define limitSwitchPin1 44  // Change this to the appropriate digital pin
#define limitSwitchPin2 45  // Change this to the appropriate digital pin
#define limitSwitchPin3 46  // Change this to the appropriate digital pin
#define limitSwitchPin4 47  // Change this to the appropriate digital pin
#define limitSwitchPin5 A2  // Change this to the appropriate digital pin
#define limitSwitchPin6 A1  // Change this to the appropriate digital pin
#define echoPin 35
#define trigPin 36
#define waterRelay 37
#define selRelay 42
#define IRSensor A0

int flag1 = 0;
int flag2 = 0;





#include <DHT.h>
#include <DHT_U.h>
#include <Servo.h>
#include "SD.h"
#include "TMRpcm.h"
#include "SPI.h"
#include <HX711_ADC.h>
#include <EEPROM.h>


#if defined(ESP8266) || defined(ESP32) || defined(AVR)
#endif

//pins:
//HX711 constructor:
const int HX711_dout = 12;  //mcu > HX711 dout pin
const int HX711_sck = 13;   //mcu > HX711 sck pin
HX711_ADC LoadCell(HX711_dout, HX711_sck);



const int calVal_eepromAdress = 0;
unsigned long t = 0;
TMRpcm tmrpcm;
unsigned long previousMillis = 0;  // Variable to store the last time the code was executed
const long interval = 1000;        // Interval in milliseconds (1 second)

unsigned long previousMillis2 = 0;  // Variable to store the last time the code was executed
const long interval2 = 10000;       // Interval in milliseconds (1 second)


int value = -1;
int value2 = -1;
float w = 0;
float newWeight = 0;
float tempe = 0;


DHT dht(DHTPIN, DHTTYPE);
Servo servo_X;
Servo servo_Y;
Servo servo_Food3;
Servo servo_Food2;
Servo servo_Food1;
Servo cleanServo;
long duration;
int distance;
int angle_X = 0;
int angle_Y = 0;
int test = 5;
int limitSwitchState1;
int limitSwitchState2;

int type1, type2, type3;
bool play = true, led = true;
int stepperPos = 1;
int mode = 1;  //0=auto 1=manual
bool light = false;
int lastFilled = 3;
bool laserPlayMode = false;
enum TaskState {
  IDLE,
  READ_TEMPERATURE,
  CHECK_LDR,
  MOVE_SERVO
};

TaskState currentTask = IDLE;
bool audioPlayed = false;

void setup() {
  Serial1.begin(9600);
  pinMode(LIGHT, INPUT_PULLUP);
  pinMode(LASER, OUTPUT);
  pinMode(RELAY, OUTPUT);
  pinMode(vacuumRelay, OUTPUT);
  pinMode(FAN_SPEED, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(trigPin, OUTPUT);  // Sets the trigPin as an Output
  pinMode(echoPin, INPUT);   // Sets the echoPin as an Input
  pinMode(IRSensor, INPUT);  // Sets the echoPin as an Input
  pinMode(waterRelay, OUTPUT); // Sets the waterRelay as an Output
  pinMode(selRelay, OUTPUT);   // Sets the waterRelay as an Output
  
  digitalWrite(FAN_SPEED, LOW);
  digitalWrite(RELAY, HIGH);
  digitalWrite(vacuumRelay, HIGH);
  dht.begin();
  
  servo_X.attach(Y);
  servo_Y.attach(X);
  servo_X.write(90);
  servo_Y.write(90);
  
  servo_Food3.attach(food3);
  servo_Food3.write(0);
  servo_Food2.attach(food2);
  servo_Food2.write(180);
  servo_Food1.attach(food1);
  servo_Food1.write(180);
  
  digitalWrite(LASER, HIGH); // turn the LASER ON
  
  type1 = type2 = type3 = 0;
  
  pinMode(stepPin, OUTPUT);
  pinMode(dirPin, OUTPUT);
  pinMode(enPin, OUTPUT);
  
  pinMode(stepPin2, OUTPUT);
  pinMode(dirPin2, OUTPUT);
  pinMode(enPin2, OUTPUT);
  
  pinMode(stepPin3, OUTPUT);
  pinMode(dirPin3, OUTPUT);
  pinMode(enPin3, OUTPUT);
  
  pinMode(limitSwitchPin1, INPUT);
  pinMode(limitSwitchPin2, INPUT);
  pinMode(limitSwitchPin3, INPUT);
  pinMode(limitSwitchPin4, INPUT);
  pinMode(limitSwitchPin5, INPUT);
  pinMode(limitSwitchPin6, INPUT);
  
  pinMode(IRSensor, INPUT);
  
  pinMode(stepPin4, OUTPUT);
  pinMode(dirPin4, OUTPUT);
  
  cleanServo.attach(pinCleanServo);
  cleanServo.write(120);
  

  digitalWrite(enPin, LOW);
  digitalWrite(enPin2, LOW);
  digitalWrite(enPin3, LOW);
  digitalWrite(waterRelay, HIGH);
  digitalWrite(selRelay, LOW);
  
  digitalWrite(limitSwitchPin1, HIGH);
  digitalWrite(limitSwitchPin2, HIGH);
  digitalWrite(limitSwitchPin3, HIGH);
  digitalWrite(limitSwitchPin4, HIGH);
  digitalWrite(limitSwitchPin5, HIGH);
  digitalWrite(limitSwitchPin6, HIGH);
  
  
  delay(1000);
  
  tmrpcm.speakerPin = 11;
  
  if (!SD.begin(SD_ChipSelectPin)) {
    //Serial.println("SD card initialization failed!");
    // Stop the program if initialization fails
  }
  
  tmrpcm.setVolume(5);
  //Serial.println("SD card initialized successfully");
  //playMusic();
  
  // testing food module start
  
  // testing food module end
  
  // weight food start
  LoadCell.begin();
  
  float calibrationValue;    // calibration value (see example file "Calibration.ino")
  calibrationValue = 98.02;  // uncomment this if you want to set the calibration value in the sketch
#if defined(ESP8266) || defined(ESP32)
  //EEPROM.begin(512); // uncomment this if you use ESP8266/ESP32 and want to fetch the calibration value from eeprom
#endif
  //EEPROM.get(calVal_eepromAdress, calibrationValue); // uncomment this if you want to fetch the calibration value from eeprom

  unsigned long stabilizingtime = 2000;
  boolean _tare = true;
  LoadCell.start(stabilizingtime, _tare);
  if (LoadCell.getTareTimeoutFlag()) {
    //Serial.println("Timeout, check MCU>HX711 wiring and pin designations");
    while (1);
  } else {
    LoadCell.setCalFactor(calibrationValue);
    //Serial.println("Startup is complete");
  }
}

//type1 to type2  267    high
//type2 to type1  267    low
//type1 to type3  267    low
//type3 to type1  267    high
//type2 to type3  267    high
//type3 to type2  267    low

void loop() {

  if (laserPlayMode) {
    handleLaserPlay();
  } else {

    unsigned long currentMillis = millis();  // Get the current time
    if (currentMillis - previousMillis2 >= interval2) {
      previousMillis2 = currentMillis;
      w = wight();
      
      //Serial.println("Final weight=" + String(w));
      delay(100);
      
      
    }
    if (currentMillis - previousMillis >= interval) {
      previousMillis = currentMillis;  // Save the current time for the next iteration
      

      if (w <= 50) {
        Serial1.println("w=Almost Empty");
      } else if (w > 50 && w <= 200) {
        Serial1.println("w=Enough Food");
      } else if (w > 200) {
        Serial1.println("w=Almost Full");
      }


      tempe = readTemperature();
      Serial1.println("t=" + String(tempe));
      int lvl = waterLevel();
      Serial.println("lvl=" + String(lvl));
      light = ldr();
      delay(50);
      if (!light) {
        Serial1.println("l=Bright");
        delay(50);
      } else {
        Serial1.println("l=Dark");
        delay(50);
      }
      if (mode == 0) {
        autoMode();
      }
    }

    if (Serial1.available() > 0) {
      // Receive the character from Serial1
      String receivedString = Serial1.readStringUntil('\n');



      //Serial.println(receivedString);
      if (receivedString[0] == 'o')
        laserPlayMode = 1;


      else if (receivedString[0] == 'l')  //auto
      {
        mode = 0;
        type1 = type2 = type3 = 0;
      }

      else if (receivedString[0] == 'k')  //manual

      {
        mode = 1;
        analogWrite(FAN_SPEED, 0);
        delay(50);
        digitalWrite(RELAY, HIGH);
      }

      else if (receivedString[0] == 'c') {
        char charBuf[receivedString.length() + 1];
        receivedString.toCharArray(charBuf, sizeof(charBuf));
        char* xString = strtok(charBuf, "=");
        char* yString = strtok(NULL, "=");


        if (xString && yString) {
          // Convert the strings to integers
          int fanSpeed = atoi(yString);
          analogWrite(FAN_SPEED, fanSpeed);
          delay(500);
        }
      } else {
        if (mode == 1) {
          mobileControl(receivedString[0]);
        }
      }
    }
  }
}



void mobileControl(char receivedChar) {
  switch (receivedChar) {
    case 'a':
      digitalWrite(RELAY, LOW);
      delay(50);

      break;
    case 'b':
      digitalWrite(RELAY, HIGH);
      delay(50);
      break;

    case 'z':
      fillCan();
      break;
    case 'e':
      type1 = 1;
      break;
    case 'f':
      type1 = 0;
      break;
    case 'g':
      type2 = 1;
      break;
    case 'h':
      type2 = 0;
      break;
    case 'i':
      type3 = 1;
      break;
    case 'j':
      type3 = 0;
      break;
    case 'm':
      playMusic();
      break;
    case 'n':
      tmrpcm.disable();
      delay(100);

      break;
    case 'r':
      clean();
      break;
    case 'q':
      fillWater();
      break;
    default:
      break;
  }
}

void handleLaserPlay() {
  if (Serial1.available() > 0) {
    String receivedString = Serial1.readStringUntil('\n');

    if (receivedString[0] == 'p') {
      laserPlayMode = 0;
      return;
    }
    // Separate the received string into two strings for X and Y
    char charBuf[receivedString.length() + 1];
    receivedString.toCharArray(charBuf, sizeof(charBuf));
    char* xString = strtok(charBuf, "-");
    char* yString = strtok(NULL, "-");

    if (xString && yString) {
      // Convert the strings to integers
      int joystickX = atoi(xString);
      int joystickY = atoi(yString);
      joystickX = map(joystickX, 0, 1023, 180, 0);
      servo_X.write(joystickX);
      
      // Reverse mapping for Y axis
      joystickY = map(joystickY, 0, 1023, 0, 180);
      servo_Y.write(joystickY);
      delay(4);
      // Print the joystick and servo values for debugging (optional)
      //Serial.print("Joystick X: ");
     // Serial.print(joystickX);
      //Serial.print(", Y: ");
      //Serial.println(joystickY);
    }
  }
}
void autoMode() {
  ///ldr
  if (light) {
    digitalWrite(RELAY, LOW);
    delay(50);
  } else {
    digitalWrite(RELAY, HIGH);
    delay(50);
  }
  ///////
  //////fan
  ///Serial.println(String(tempe));
  if (tempe < 25 && value != 0) {

    analogWrite(FAN_SPEED, 0);

    delay(1000);
    value = 0;
  } else if (tempe >= 25 && tempe < 30 && value != 500) {
    analogWrite(FAN_SPEED, 500);  // half speed
    //Serial.println("Case1");
    delay(1000);
    value = 500;
  } else if (tempe >= 30 && value != 1000) {

    analogWrite(FAN_SPEED, 1000);  // max speed
    //Serial.println("Case2");
    delay(1000);
    value = 1000;
  }
  ////////
  ////////Food
  w = wight();

  if (w < 50) {
    if (lastFilled == 3) {
      type1 = 1;
      type2 = 0;
      type3 = 0;
      lastFilled = 1;

    } else if (lastFilled == 1) {
      type1 = 0;
      type2 = 1;
      type3 = 0;
      lastFilled = 2;
    } else if (lastFilled == 2) {
      type1 = 0;
      type2 = 0;
      type3 = 1;
      lastFilled = 3;
    }
    fillCan();
  }
}



//type1 to type2  267    high
//type2 to type1  267    low
//type1 to type3  267    low
//type3 to type1  267    high
//type2 to type3  267    high
//type3 to type2  267    low

void fillCan() {
  if (type1 == 1 && type2 == 0 && type3 == 0) {


    float w2 = w;
    float old = w2;
    while (w2 < 220) {
      servo_Food1.write(100);
      delay(1000);

      servo_Food1.write(180);
      delay(50);
      w2 = wight();
      //Serial.print("w2=" + String(w2));
      if (abs(old - w2) < 5) {
        break;
      }
      old = w2;
      delay(50);
    }



  } else if (type1 == 0 && type2 == 1 && type3 == 0) {


    digitalWrite(dirPin, HIGH);  //Changes the rotations direction
    moveStepper();


    float w2 = w;
    float old = w2;
    while (w2 < 220) {
      servo_Food2.write(100);
      delay(1000);

      servo_Food2.write(180);
      delay(50);
      w2 = wight();
      //Serial.print("w2=" + String(w2));
      if (abs(old - w2) < 5) {
        break;
      }
      old = w2;
      delay(50);
    }
    digitalWrite(dirPin, LOW);  //Changes the rotations direction
    delay(50);
    moveStepper();
  } else if (type1 == 0 && type2 == 0 && type3 == 1) {


    digitalWrite(dirPin, LOW);  //Changes the rotations direction
    delay(50);
    moveStepper();


    float w2 = w;
    float old = w2;
    while (w2 < 220) {
      servo_Food3.write(80);
      delay(1000);

      servo_Food3.write(0);
      delay(50);
      w2 = wight();
      //Serial.print("w2=" + String(w2));
      //Serial.println(String(w2));
      if (abs(old - w2) < 5) {
        break;
      }
      old = w2;
      delay(50);
    }
    digitalWrite(dirPin, HIGH);  //Changes the rotations direction
    delay(50);
    moveStepper();
  } else if (type1 == 1 && type2 == 1 && type3 == 0) {


    float w2 = 220 - w;
    float wt1 = (w2 / 2.0) + w;
    w2 = wight();
    float old = w2;
    while (w2 < wt1) {
      servo_Food1.write(100);
      delay(500);

      servo_Food1.write(180);
      delay(50);
      w2 = wight();
      //Serial.print("w2=" + String(w2));
      if (abs(old - w2) < 5) {
        break;
      }
      old = w2;
      delay(50);
    }
    digitalWrite(dirPin, HIGH);  //Changes the rotations direction
    delay(50);
    moveStepper();
    w2 = w;
    old = w2;
    while (w2 < 220) {
      servo_Food2.write(100);
      delay(500);

      servo_Food2.write(180);
      delay(50);
      w2 = wight();
      //Serial.print("w2=" + String(w2));
      if (abs(old - w2) < 5) {
        break;
      }
      old = w2;
      delay(50);
    }
    digitalWrite(dirPin, LOW);  //Changes the rotations direction
    delay(50);
    moveStepper();
  }

  else if (type1 == 1 && type2 == 0 && type3 == 1) {
    float w2 = 220 - w;
    float wt1 = (w2 / 2.0) + w;
    w2 = wight();
    float old = w2;
    while (w2 < wt1) {
      servo_Food1.write(100);
      delay(500);

      servo_Food1.write(180);
      delay(50);
      w2 = wight();
      //Serial.print("w2=" + String(w2));
      if (abs(old - w2) < 5) {
        break;
      }
      old = w2;
      delay(50);
    }
    digitalWrite(dirPin, LOW);  //Changes the rotations direction
    moveStepper();
    w2 = w;
    old = w2;
    while (w2 < 220) {
      servo_Food3.write(80);
      delay(500);

      servo_Food3.write(0);
      delay(50);
      w2 = wight();
      //Serial.print("w2=" + String(w2));
      if (abs(old - w2) < 5) {
        break;
      }
      old = w2;
      delay(50);
    }
    digitalWrite(dirPin, HIGH);  //Changes the rotations direction
    delay(50);
    moveStepper();
  } else if (type1 == 0 && type2 == 1 && type3 == 1) {
    digitalWrite(dirPin, HIGH);  //Changes the rotations direction
    delay(50);
    moveStepper();
    float w2 = 220 - w;
    float wt1 = (w2 / 2.0) + w;
    w2 = wight();
    float old = w2;
    while (w2 < wt1) {
      servo_Food2.write(100);
      delay(500);
      servo_Food2.write(180);
      delay(50);
      w2 = wight();
      //Serial.print("w2=" + String(w2));
      if (abs(old - w2) < 5) {
        break;
      }
      old = w2;
      delay(50);
    }

    moveStepper();
    w2 = w;
    old = w2;
    while (w2 < 220) {
      servo_Food3.write(80);
      delay(500);

      servo_Food3.write(0);
      delay(50);
      w2 = wight();
      //Serial.print("w2=" + String(w2));
      if (abs(old - w2) < 5) {
        break;
      }
      old = w2;
      delay(50);
    }
    digitalWrite(dirPin, LOW);  //Changes the rotations direction
    moveStepper();

    moveStepper();
  }

  // else if( type1==1 && type2==1 && type3==1)
  // {
  //   if(stepperPos==1)
  //   {
  //     servo_Food1.write(100);
  //     delay(1000);
  //     servo_Food1.write(180);
  //     digitalWrite(dirPin,HIGH); //Changes the rotations direction
  //     moveStepper();
  //     servo_Food2.write(100);
  //     delay(1000);
  //     servo_Food2.write(180);
  //     digitalWrite(dirPin,HIGH); //Changes the rotations direction
  //     moveStepper();
  //     servo_Food3.write(100);
  //     delay(1000);
  //     servo_Food3.write(180);
  //     stepperPos=3;
  //   }
  //   else if(stepperPos==2)
  //   {
  //     servo_Food2.write(100);
  //     delay(1000);
  //     servo_Food2.write(180);
  //     digitalWrite(dirPin,HIGH); //Changes the rotations direction
  //     moveStepper();
  //     servo_Food3.write(100);
  //     delay(1000);
  //     servo_Food3.write(180);
  //     digitalWrite(dirPin,HIGH); //Changes the rotations direction
  //     moveStepper();
  //     servo_Food1.write(100);
  //     delay(1000);
  //     servo_Food1.write(180);
  //     stepperPos=1;
  //   }
  //    else if(stepperPos==3)
  //   {
  //       servo_Food3.write(100);
  //       delay(1000);
  //       servo_Food3.write(180);
  //       digitalWrite(dirPin,LOW); //Changes the rotations direction
  //       moveStepper();
  //       servo_Food2.write(100);
  //       delay(1000);
  //       servo_Food2.write(180);
  //       digitalWrite(dirPin,LOW); //Changes the rotations direction
  //       moveStepper();
  //       servo_Food1.write(100);
  //       delay(1000);
  //       servo_Food1.write(180);
  //       stepperPos=1;
  //   }
}

//type1 to type2  267    high
//type2 to type1  267    low
//type1 to type3  267    low
//type3 to type1  267    high
//type2 to type3  267    high
//type3 to type2  267    low




float wight() {
  float temp;
  static boolean newDataReady = false;
  for (int i = 0; i < 150; i++) {
    delay(25);
    // check for new data/start next conversion:
    if (LoadCell.update()) {
      newDataReady = true;
    }

    // get smoothed value from the dataset:
    if (newDataReady) {
      temp = LoadCell.getData();

      newDataReady = false;
    }

    // receive command from serial terminal, send 't' to initiate tare operation:
   

    // check if last tare operation is complete:
    
  }
  return temp;
}


bool ldr() {

  int L = digitalRead(LIGHT);  // read the light sensor
  delay(10);
  if (L == HIGH && value2 != 1) {
    value2 = 1;
    return true;
  } else if (L == LOW && value2 != 0) {
    value2 = 0;
    return false;
  }



  //delay(3000);
}
float readTemperature() {

  float t = dht.readTemperature();

  //Serial.print("Temperature: ");
  //Serial.print(t);
  //Serial.println(" °C");
  return t;
  // if (t < 25&&value!=0)
  //   {
  //     analogWrite(FAN_SPEED, 0);
  //     delay(100);
  //     value=0;
  //   }
  // else if (t >= 25 && t < 30&&value!=500)
  //   {
  //     analogWrite(FAN_SPEED, 500); // half speed
  //     delay(100);
  //     value=500;
  //   }
  // else if (t >= 30 && value!=1000)
  //   {

  //     analogWrite(FAN_SPEED, 1000); // max speed
  //     delay(100);
  //     value=1000;
  //   }
}
void laser(int i, int j) {
  int loop = i;
  if (j > i)
    loop = j;
  /*  for(angle_X=0;angle_X<=i;angle_X++)
  {
    servo_X.write(angle_X);
    servo_Y.write(angle_X);
    //servo_X.write(angle_Y);
    delay(10);
  }
  delay(1000);
   for(angle_X=i;angle_X>=0;angle_X--)
  {
    servo_X.write(angle_X);
    servo_Y.write(angle_X);
    delay(10);
  }
  angle_X=0;*/

  /*for(angle_Y=0;angle_Y<=j;angle_Y++)
  {
    servo_Y.write(angle_Y);
    //servo_X.write(angle_Y);
    delay(10);
  }
  delay(1000);
   for(angle_Y=j;angle_Y>=0;angle_Y--)
  {
    servo_Y.write(angle_Y);
    //servo_X.write(angle_Y);
    delay(10);
  }
  angle_Y=0;*/

  for (int k = 0; k <= loop; k++) {
    if (k <= i) {
      servo_X.write(angle_X);
      angle_X++;
    }
    if (k <= j) {

      servo_Y.write(angle_Y);
      angle_Y++;
    }
    //servo_X.write(angle_Y);
    delay(5);
  }
  delay(1000);
  for (int k = loop; k >= 0; k--) {
    if (k <= i) {
      servo_X.write(angle_X);
      angle_X--;
    }
    if (k <= j) {
      servo_Y.write(angle_Y);
      angle_Y--;
    }
    delay(5);
  }

  angle_X = 0;
  angle_Y = 0;
}
void playMusic() {

  tmrpcm.play("gg.wav");
  delay(100);
}

void clean() {
  limitSwitchState1 = digitalRead(limitSwitchPin1);
  limitSwitchState2 = digitalRead(limitSwitchPin4);
  digitalWrite(dirPin3, HIGH);  //Changes the rotations direction
  delay(10);
  digitalWrite(dirPin2, HIGH);
  delay(10);
  int sensorStatus;
  while (true) {

    if (limitSwitchState1 == HIGH) {
      digitalWrite(stepPin2, HIGH);
      delayMicroseconds(100);
      digitalWrite(stepPin2, LOW);
      delayMicroseconds(100);
      limitSwitchState1 = digitalRead(limitSwitchPin1);
      delayMicroseconds(10);
    }
    if (limitSwitchState2 == HIGH) {
        if(flag1==0){
        sensorStatus = digitalRead(IRSensor);  // Set the GPIO as Input
        delayMicroseconds(10);
        }
      
      
        if(sensorStatus==0&&flag1==0){
          
        cleanServo.write(32);
        delay(500);
        
        flag1=1;
        }
  

      digitalWrite(stepPin3, HIGH);
      delayMicroseconds(100);
      digitalWrite(stepPin3, LOW);
      delayMicroseconds(100);
      limitSwitchState2 = digitalRead(limitSwitchPin4);
      delayMicroseconds(10);
    }

    if (limitSwitchState1 == LOW && limitSwitchState2 == LOW) {
      
      break;
    }
  }
  //Shift1 Done
  
  cleanServo.write(120);
  delay(500);
  limitSwitchState1 = digitalRead(limitSwitchPin2);
  limitSwitchState2 = digitalRead(limitSwitchPin3);
  digitalWrite(dirPin3, LOW);  //Changes the rotations direction
  digitalWrite(dirPin2, LOW);
  while (true) {

    if (limitSwitchState1 == HIGH) {
      digitalWrite(stepPin2, HIGH);
      delayMicroseconds(100);
      digitalWrite(stepPin2, LOW);
      delayMicroseconds(100);
      limitSwitchState1 = digitalRead(limitSwitchPin2);
      delayMicroseconds(10);
    }
    if (limitSwitchState2 == HIGH) {
      digitalWrite(stepPin3, HIGH);
      delayMicroseconds(100);
      digitalWrite(stepPin3, LOW);
      delayMicroseconds(100);
      limitSwitchState2 = digitalRead(limitSwitchPin3);
      delayMicroseconds(10);
    }

    if (limitSwitchState1 == LOW && limitSwitchState2 == LOW) {
      break;
    }
  }
  //Vacuum
  digitalWrite(vacuumRelay, LOW);
  limitSwitchState1 = digitalRead(limitSwitchPin5);
  digitalWrite(dirPin4, LOW);  //Changes the rotations direction

  while (limitSwitchState1 == HIGH) {
    digitalWrite(stepPin4, HIGH);
    delayMicroseconds(4000);
    digitalWrite(stepPin4, LOW);
    delayMicroseconds(4000);
    limitSwitchState1 = digitalRead(limitSwitchPin5);
    delayMicroseconds(10);
  }
  delay(500);
  limitSwitchState1 = digitalRead(limitSwitchPin6);
  digitalWrite(dirPin4, HIGH);
  while (limitSwitchState1 == HIGH) {
    digitalWrite(stepPin4, HIGH);
    delayMicroseconds(4000);
    digitalWrite(stepPin4, LOW);
    delayMicroseconds(4000);
    limitSwitchState1 = digitalRead(limitSwitchPin6);
    delayMicroseconds(10);
  }

  flag1 = 0;
  digitalWrite(vacuumRelay, HIGH);
}
// void loop()
// {


// if (millis() - ldrTimer >= ldrInterval) {
//     ldr();
//     ldrTimer = millis();
//   }
//    // ldr();
//   //   led=false;

//  if (millis() - temperatureTimer >= temperatureInterval) {
//     readTemperature();
//     temperatureTimer = millis();
//   }
//   //readTempruture();
//   // Tempruture System end
// /*if(play)
//  {
//     playMusic();
//     play=false;
// }*/
// //delay(500);

// /*for(angle_X=0;angle_X<=180;angle_X++)
//   {
//     servo_X.write(angle_X);
//     //servo_X.write(angle_Y);
//     delay(10);
//   }
//   delay(1000);
//    for(angle_X=180;angle_X>=0;angle_X--)
//   {
//     servo_X.write(angle_X);
//     //servo_X.write(angle_Y);
//     delay(10);
//   }
//   angle_X=0;
//   delay(500);*/
// }


void moveStepper() {
  for (int x = 0; x < 267; x++) {
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(2000);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(2000);
  }
  delay(100);
}
int waterLevel() {

  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  // Sets the trigPin on HIGH state for 10 micro seconds
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  // Reads the echoPin, returns the sound wave travel time in microseconds
  duration = pulseIn(echoPin, HIGH);
  // Calculating the distance
  distance = duration * 0.034 / 2;
  return distance;
}

void fillWater() {
  int level = waterLevel();
  //Serial.println("level=" + String(level));

    if(level>=4){

    digitalWrite(waterRelay, LOW);
    digitalWrite(selRelay, HIGH);
    delay(7000);
    
    digitalWrite(waterRelay, HIGH);
    digitalWrite(selRelay, LOW);
    delay(1000);
    }

  
  
}

type or paste code here

You need to provide both code and schematics. Due to the large numer of devices, draw one of multiple devices.
Motor currents are not allowed for the breadboard.

Your way of testing one subsystem at the time is really good!
Did You then add one system at the time to the project? That's preferable.

EDIT: delay shouldn't be used.
Please provide a map over the code like flow charts. Which modes/modules are active at the same time.

thx bro appreciated
i provided the code in the schematic above, it recieves at serial1 from ESP

im very sus about bread boards, im really willing to unwire the whole system tomorrow and soldering it, will that help in your opinion?
giving schematic is really hard since i didnt draw it, i used one

How will you solder it correctly without schematic?
How will you check it? Put the plug in and wait for black smoke to escape?

Interesting.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.