I need assistance for a wall avoiding robot.

Thanks

Please use code tags (</> button on the toolbar) when you post code or warning/error messages. The reason is that the forum software can interpret parts of your code as markup, leading to confusion, wasted time, and a reduced chance for you to get help with your problem. This will also make it easier to read your code and to copy it to the IDE or editor. Using code tags and other important information is explained in the How to use this forum post. Please read it.

Please explain exactly what you need help with. If you’re encountering an error then post the full error message, also using code tags.

This ought to work, assuming sensor1 is on the left, sensor2 is in the middle, and sensor3 is on the right, and this code is in the loop() function.

while(distance2 <= 30) {
    // First sensor input/output init
  digitalWrite(trigPin1, LOW);
  delayMicroseconds(2);

  digitalWrite(trigPin1, HIGH);
  delayMicroseconds(10);

  digitalWrite(trigPin1, LOW);

  duration1 = pulseIn(echoPin1, HIGH);

  distance1 = duration1 / 58.2;

    // Second Sensor input/output init
  digitalWrite(trigPin2, LOW);
  delayMicroseconds(2);

  digitalWrite(trigPin2, HIGH);
  delayMicroseconds(10);

  digitalWrite(trigPin2, LOW);

  duration2 = pulseIn(echoPin2, HIGH);

  distance2 = duration2 / 58.2;

    // Third Sensor input/output init
  digitalWrite(trigPin3, LOW);
  delayMicroseconds(2);

  digitalWrite(trigPin3, HIGH);
  delayMicroseconds(10);

  digitalWrite(trigPin3, LOW);

  duration3 = pulseIn(echoPin3, HIGH);

  distance3 = duration3 / 58.2;
  if(distance1 > distance3 && distance1 > 35 /*Arbitrary distance*/) {
    moveBot(0, 1.0); //Arbitary speeds, will turn on the spot, could be moveBot(0.5, 1.0);
  } else if(distance3 > distance1 && distance3 > 35) /*Arbitrary distance*/ {
    moveBot(1.0, 0); //Arbitary speeds, will turn on the spot, could be moveBot(1.0, 0.5);
  } else {
    moveBot(1.0, 0); //Arbitary speeds, will turn on the spot, could be moveBot(1.0, 0.5);
    delay(100); //Arbitrary delay
  }
}
moveBot(1.0, 1.0);

I haven’t tested it on a robot, but it ought to do the job, assuming moveBot() works fine. I can’t see any errors, but you might need to troubleshoot a bit. I’m NOT a perfect programmer. The delays, distances, and speeds are all arbitrary, you might need to increase/decrease some of them depending on how fast your robot goes.