Just another program for my bot: 4 Ping sensors with Buzzer alarm (updated)

When you say 'not easy to maintain', you mean not easily optimized, changed, upgraded, etc...?

And more. If you change to a different type of sensor, you have a lot of code to change now. Put one of the similar blocks of code in a function, and you have 1/3 as much code to maintain, optimize, change, upgrade, etc. (comment, document...).

Seems to be a lot about variables..

It is all about variables, and how much of the code can see (and modify, inadvertently or deliberately) the variable. A global variable can be seen by all the code in a file. A local variable can be seen by much less code. Limiting the scope of a variable is usually a good thing.

Also, when you say atomic functions, this is when you can complete a function in one clock cycle, without any interruptions or unnecessary rendundancies?

There are multiple meanings to "atomic". A function will not complete in one clock cycle. It takes more than one clock cycle to push the return code onto the stack, branch to the proper place, and pop the value off the stack. In the case of functions, atomic means that it does one thing. A function like digitalRead() does one thing - it returns the value of a digital pin. Now, it may take a lot of steps to convert the pin number to a port, to actually get the value, etc. But, that is encapsulated in the function, and you do not need to understand how it does it's magic to perform the one task that is set for it.

On the other hand, a function like buzzIfDistanceIsLessThan24Inches(int sensorPin1, int sensorPin2, int sensorPin3, int buzzerPin), is not an atomic function. It does not do one thing. It does several things. You should strive to develop functions like analogRead(), digitalWrite(), etc. that do one thing, and do that one thing well. Such functions are easy to name.

You will be tempted, sooner or later, to develop functions that are hard to name, because they do more than one thing. Resist that temptation, and make two (or more) functions.