Help with code.

I am having some issues coding. I am trying to get my robot to do the following in the video I have provided. My only issue is that I am unsure of how to code it so that after the button has been pressed that it will back up and adjust from bumping into the walls. Any help is much appreciated. Thanks!

Video Link.

It’s just a simple if statement.


void lineUp(){
//code to line up
}

task main(){
if(SensorValue[button] == 1){
lineUp();
}
}