Robot turning code

Thanks for the help, with the state machine and timer would something like this be fitting?

int MaxState = 4
int          state;

unsigned long Period = 1000;
unsigned long msecLst;
int motoraf = 5;
int motorab = 6;
int motorbf = 11;
int motorbb = 12;

void setup() {
  // put your setup code here, to run once:
Serial.begin (9600);
pinMode(motoraf, OUTPUT);
pinMode(motorab, OUTPUT);
pinMode(motorbf, OUTPUT);
pinMode(motorbb, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
unsigned long msec = millis ();
//is it time to proceed to the next part of the code?
    if ((msec - msecLst) < Period)
//no it isn't
        return;
//now it is
    msecLst = msec;
//stating the code
    switch (state)  {
    
    
    case 0: //first part it should do
        Serial.println ("state 0");
        digitalWrite(motorab, HIGH); //left wheel going backwards
        digitalWrite(motorbb, HIGH); //right wheel going backwards
        Period = 2000UL; //time it should go backwards for
        state++; //adds 1 to the value of state so it can go to the next one
        break;

    case 1:
        Serial.println ("state 1");
        digitalWrite(motorab, LOW); //stops left wheel going back
        digitalWrite(motorbb, LOW); //stops right wheel going back
        digitalWrite(motorbf, HIGH); //makes only right wheel go forward
        Period = 2000UL; //time the right wheel should turn for, should make body go left
        state++;
        break;
    
    case 2:
        Serial.println ("state 2");
        digitalWrite(motoraf, HIGH); //makes left wheel join the right, should make rover go forward normally
        Period = 6000UL; //time it should take going forward (away from obstacle)
        state++;
        break;

    case 3:
        Serial.println ("state 3");
        digitalWrite(motorbf, LOW); //stops turning right wheel forward (left wheel turning so it should turn left back into original position)
        Period = 2000;; //time it should take turning back into og rotation
        state = 0;
        break;
    }}