Program not executing as expecte

I am using the Arduino IDE to create programs for the Tetrix Prizm Robotics controller based on the Arduino Genuino Uno and the code is not executing as expected. I have included the code below. In the void loop i have a series of statements that send the robot forward at 50% motor power and then call a function to use the sonar sensor to check distance and execute another function to turn and then My intent is for it to return to the void loop and continue to run the statements until complete.

#include <PRIZM.h> // include PRIZM library
PRIZM prizm; // instantiate a PRIZM object “prizm” so we can use its functions

void pauseR();
void pauseL();
void rightTurn();
void leftTurn();

void setup() {
prizm.PrizmBegin(); // initialize PRIZM
prizm.setMotorInvert(1, 1); // invert the direction of DC Motor 1 to harmonize direction
}

void loop() {
prizm.setMotorPowers(50, 50);
pauseL();
prizm.setMotorPowers(50, 50);
pauseR();
prizm.setMotorPowers(50, 50);
pauseR();
prizm.setMotorPowers(50, 50);
pauseL();
}

void pauseR() { //pause robot and turn right
while (prizm.readSonicSensorCM(4) < 25)
{
prizm.setMotorPowers(125, 125); // stop both motors with in brake mode
rightTurn();

}
}
void pauseL() {
while (prizm.readSonicSensorCM(4) < 25)
{
prizm.setMotorPowers(125, 125); // stop both motors with in brake mode
leftTurn();

}
}

void rightTurn() { // function for a right turn
prizm.setMotorPowers(-50, 50); // make a right turn
delay(600); // wait here for .6 seconds while motors spin
prizm.setMotorPowers(125, 125); // stop both motors with in brake mode
delay(1000); // wait here for 1 second
return;
}
void leftTurn() { // function for a right turn
prizm.setMotorPowers(50, -50); // make a right turn
delay(600); // wait here for .6 seconds while motors spin
prizm.setMotorPowers(125, 125); // stop both motors with in brake mode
delay(1000); // wait here for 1 second
return;
}

What does the code actually do?

Read the how to use this forum sticky to see how to properly post code.

You should include a link to any libraries that do not come with the Arduino IDE.

It allows a robot to look for objects along it's path using a Sonic sensor and turn either right or left depending on the function called when it encounters them.

rduino Genuino Uno and the code is not executing as expected.

We need to know in what way does the code not execute as expected.

I do not see any serial prints in the sketch. Serial print is the best troubleshooting tool that you have. Add A Serial.begin(9600) to setup and some prints in the code to monitor the code execution progress and variable values. Then you may see where the problem is.

The code looks OK to me. It will move forward until it gets within 25 distance units (cm?) of an obstacle. Then, depending on which of the 'pause' functions is being called, it will stop, turn for 600 milliseconds, stop, pause for a second and check for an obstacle repeatedly until no obstacle is seen, then return to moving forward. Since you have an equal number of 'pauseL' and 'pauseR' calls it will rotate left about 50% of the time and rotate right about 50% of the time.

Is that what you wanted?