Car that beeps

So I am trying to code for a car controlled by an Arduino Uno that needs to start from the middle of an open box, touch the right wall and play a tone, touch the left wall and play a tone, then return back to it's starting position.

So far I have code with states for turning left, right, going forward and backward, but I am unsure how to string them together.

MilestoneTwo.ino (1.78 KB)

More members will see your code if you post your code as described in the forum guidelines.

I cannot see your code on my mobile device if you do not follow the instructions.

What I write here may sound a bit rude. It is not meant rude. It is meant to be clear and easy to understand.

If you want help you should make it as much comfortable for your potential helpers instead of making it most comfortable for you. Post code inside code-tags.

In your code add your first approach how you think the code inside your state1(), state2()-function looks like
It does not even have to compile. Just a small starting point that shows some effort invested by YOU

or as an alternative

post at least one single BUT CONCRETE question about one line of code instead of a generalised question like

"So far I have code with states for turning left, right, going forward and backward, but I am unsure how to string them together."

What your code shows so far is copy&paste from a tutorial and a few minor changes to the copied code.

best regards Stefan