roaming tank

OK so i am kind of new to this ,
so far i have constructed the tank in the pic below
components:
Audrino mega
motor shield (added heat sync)
4 ping (parallax)
servo
2 motors (3V i think)

I looked over several sketches for Wandering with ping but still confused on how to modify for current hardware

Picture 1.jpg

What needs to be modified?

I can get it to spit out ranges from the sensors
however i am unsure of how to get it to change directions based on ranges
or is it that i should us IF statements?

invad8er:
I can get it to spit out ranges from the sensors
however i am unsure of how to get it to change directions based on ranges
or is it that i should us IF statements?

"if" statements are the easiest way. Take a look at a sketch that I did with Ping sensor and servos.

I also recommend the "NewPing" library.
Download
Documentation

#include <Servo.h>

#define trigPin 8
#define echoPin 9
Servo righteyelid;
Servo lefteyelid;
int pos = 0;

void setup() {
  Serial.begin (9600);
  righteyelid.attach(50);
  lefteyelid.attach(52);
  pinMode(trigPin,OUTPUT);
}

void loop() {
  int duration, distance;
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(1000);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration/2) / 29.1;
  if (distance <= 10)
  {
    //Serial.print(distance);
    Serial.println("servo on");
    righteyelid.write(65);
    lefteyelid.write(135);
  }
  
  else {
    Serial.print(distance);
    Serial.println(" cm");
    righteyelid.write(95);
    lefteyelid.write(96);
    
  }
  delay(5);
}