I am trying to build a code that drives in a rectangle around the field but also utilizes a distance sensor. The goal is to have the robot drive in the rectangle but if the distance sensor senses an object within an inch Infront of it the robot will drive around the object and continue the rectangle. This is purely a personal goal for me to play around with programming, but I have not found out a way to accomplish this. I have the program for a rectangle and a program for the distance sensor (not in autonomous though) but I cannot figure out how to combine them. Any help is appreciated.
Here is an idea:
Since you already seem to have made progress on each individual component, to help you decide how to combine them, you could try making a flow chart describing the logic and/or the structure of your program. Once you have made a high level flow chart, you can start breaking it up even further. In the professional world, I believe this type of visualization is called UML. (or, at least is similar to UML)