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

PaulS:

was wondering if I can improve it in any way

Yes, you can. You have a bunch of global variables that are only used in loop(). Those should be local in scope, instead.

Many of them are not actually used at all, since you have local variables of the same name.

You have 3 nearly identical blocks of code. One copy should be in a function that takes a pin number as an argument and returns a distance value. In loop(), then, you should just make 3 calls to that function.

Thanks Paul, will go back and try what you said and post back.

or make it more efficient.

For you? For the compiler? For the Arduino?

I believe all 3 go hand in hand :slight_smile: For me in the long run & better software makes for better use of hardware ...i guess? hehe