Mini 04 board, using 2 sr04 sensors, with 4 relays, really need help

I'm not the greatest at programming. So far I've been reading through the stuff on this site for a while but can't think how to get this.

So I have what's in the title. As sensor 1 is less than so many cm, I want one of the relays low, etc. I can give details more but I just need help getting started on it. Like, helper code I guess.

int sensorFrontInput = 7;
int sensorFrontEcho = 8;
int sensorSideInput = 3;
int sensorSideEcho = 4;

int relay1 = 10;
int relay2 = 11;
int relay3 = 12;
int relay4 = 13;

int frontLimit = 20;
int sideLimit1 = 30;
int sideLimit2 = 70;

void setup() {

pinMode(8, INPUT);
pinMode(7, INPUT);
pinMode(4, INPUT);
pinMode(3, INPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);

}

double ping(int outPin, int inPin) //Get CM to obstacle in front of the sensor
{
long duration;
pinMode(outPin, OUTPUT);
pinMode(inPin, INPUT);
digitalWrite(outPin, LOW);
delayMicroseconds(2);
digitalWrite(outPin, HIGH);
delayMicroseconds(10);
digitalWrite(outPin, LOW);
delayMicroseconds(10);
duration = pulseIn(inPin, HIGH);
return duration / 29.0 / 2.0;
}

void stop(){
digitalWrite(relay2, HIGH);
}

void reverse(){
digitalWrite(relay1, HIGH);
}

void turnLeft(){
digitalWrite(relay3, HIGH);
}

void turnRight(){
digitalWrite(relay3, HIGH);
digitalWrite(relay4, HIGH);
}

void loop()
{
int distanceFront = ping(sensorFrontInput, sensorFrontEcho);
int distanceSide = ping(sensorSideInput, sensorSideEcho);
if (distanceFront < frontLimit){
turnLeft();}
if (distanceSide < sideLimit1){
turnRight();}
// if ((distanceFront > frontLimit) and (distanceSide < sideLimit2)){
// pass}
if (distanceSide > sideLimit2){
turnRight();}
delay(500);
}

actually, I've tried writing this so far. It compiles, I'm not sure how it'll work because I can't seem to get it to upload onto the mini 04. Keep getting this:
avrdude: stk500_2_ReceiveMessage(): timeout
avrdude: stk500_2_ReceiveMessage(): timeout
repeating on...

  int sensorFrontInput = 7;
  int sensorFrontEcho = 8;
  int sensorSideInput = 3;
  int sensorSideEcho = 4;

  pinMode(8,   INPUT);
  pinMode(7,   INPUT);
  pinMode(4, INPUT);
  pinMode(3, INPUT);

What's the purpose of assigning names if you don't use them?

There is no code anywhere to turn any relay off. Once turned on, they stay on. If that is your intent, why not get rid of the sensors and most of the code, and just turn all the relays on in setup()? If that was not the intent, back to the drawing board.

It compiles, I'm not sure how it'll work because I can't seem to get it to upload onto the mini 04.

This isn't a programming problem. Have you ever gotten a sketch to upload? If not, try posting in the Using Arduino :: Installation and Troubleshooting section (after following all the steps in Help + Troubleshooting on the IDE menu).

I'm just trying to keep some style I guess. But yeah, changed that, thanks!

int sensorFrontInput = 7;
int sensorFrontEcho = 8;
int sensorSideInput = 3;
int sensorSideEcho = 4;

int relay1 = 10;
int relay2 = 11;
int relay3 = 12;
int relay4 = 13;

int frontLimit = 20;
int sideLimit1 = 30;
int sideLimit2 = 70;

void setup() {

pinMode(sensorFrontEcho, INPUT);
pinMode(sensorFrontInput, INPUT);
pinMode(sensorSideEcho, INPUT);
pinMode(sensorSideInput, INPUT);
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);
pinMode(relay3, OUTPUT);
pinMode(relay4, OUTPUT);

}

double ping(int outPin, int inPin) //Get CM to obstacle in front of the sensor
{
long duration;
pinMode(outPin, OUTPUT);
pinMode(inPin, INPUT);
digitalWrite(outPin, LOW);
delayMicroseconds(2);
digitalWrite(outPin, HIGH);
delayMicroseconds(10);
digitalWrite(outPin, LOW);
delayMicroseconds(10);
duration = pulseIn(inPin, HIGH);
return duration / 29.0 / 2.0;
// The speed of sound is 340 m/s or 29 microseconds per centimeter.
// The ping travels out and back, so to find the distance of the
// object we take half of the distance travelled.
}

void stop(){
digitalWrite(relay2, HIGH);
}

void reverse(){
digitalWrite(relay1, HIGH);
}

void turnLeft(){
digitalWrite(relay3, HIGH);
}

void turnRight(){
digitalWrite(relay3, HIGH);
digitalWrite(relay4, HIGH);
}

void straight(){
digitalWrite(relay3, LOW);
digitalWrite(relay4, LOW);
digitalWrite(relay1, LOW);
digitalWrite(relay2, LOW);
}

void loop()
{
int distanceFront = ping(sensorFrontInput, sensorFrontEcho);
int distanceSide = ping(sensorSideInput, sensorSideEcho);
if (distanceFront < frontLimit){
turnLeft();}
if (distanceSide < sideLimit1){
turnRight();}
if ((distanceFront > frontLimit) and (distanceSide < sideLimit2)){
straight();}
if (distanceSide > sideLimit2){
turnRight();}
delay(200);
}

Basically I do want the default to be the relays off so that full power straight on is my default for my motors. If there's something in front I want to turn left, go to main. If something too close to that right, turn left, go to main. If nothing in the front but something between 70 to 30 cm to the right, drive straight and go to main. If there's nothing closer than 70 to the right turn right and go to main.

My ability to go straight is by default, but mainly by relay 6 and 7 being Off. Ability to turn left (or right, my wires might be crossed on that but I can switch them) is by relay3 being On. The opposite direction is by relay 3 and relay 4 being On. I could also do reverse by relay 7 On and should stop by relay 6 On.

My ability to go straight is by default, but mainly by relay 6 and 7 being Off. Ability to turn left (or right, my wires might be crossed on that but I can switch them) is by relay3 being On. The opposite direction is by relay 3 and relay 4 being On. I could also do reverse by relay 7 On and should stop by relay 6 On.

You have variables named relay1, relay2, relay3, and relay4. Which relays are you referring to here?

Why does ping return a double that you store in an int? Consistency is a good thing.

You should decide which is the most likely scenario - clear is front or blocked in front. Make that the condition of the first if test:
if(distanceFront > frontLimit)
// Go straight
else if // some other condition

Does the distance left or right matter, if there is a clear path in front?

With only two ping sensors, how can you measure left and right distances as well as front? Your logic for turning left or right needs some explaining.

As your code is now, it is possible for your robot to start turning left, then start turning right without ever having gone straight to turn all the relays off.

What exactly is it the relays control? How does turning them all off make the robot go straight?