ED-309 Daft project for a new guy

Hi All

Still very new to Arduino, bought a kit a while back and not touched for 2 years but since then Covid-19 gave me the time and brain space to dip back in. I have got to grips with many individual bits and bobs such as servos and light sensors but here is stuff I am struggling with :

1 - Most examples have a single Void loop, I'm struggling to work out how to merge sketches (whatever happened to IF, THEN, ELSE, GOTO) is there a comparison doc or page or whatever?
2 - The project I'm trying to build is a turret gun (for my kid - honest) where a single servo sweeps with an ultrasonic on top and assigns a distance value to each of the 180 degrees, then if any value changes by more than 10% or amount of mm then two more servos with ultrasonic do the same to triangulate finishing with a laser/light sensor combo to get final accuracy - NOT expecting to get given the code but a hint as to an easy way to create hundreds of variables that hold angle and distance for three servos and check changes would be handy.

To be honest I'm looking forward to the building of the gun (bit of a Ed-309 pop up using servos) and making the landscape more than the coding but cant have one without the other

All and any help greatly appreciated - Stay safe all.....

Cheers

Lee

if (conditions) {
  //put your “Execute if true” code here....
} else {
  // put your “Execute if false” code here....
}

Goto’s: don’t use them. It may have been needed 30 years ago when we only had line numbered BASIC and single line if and else statements. Now it just results in spaghetti code.

Use an array?

const int array_variable[] = { 10, 20, 30, 40, 50 };

Hard to say further without a concrete example. Post some code if you want specific help.

Scorpinator:
Most examples have a single Void loop, I'm struggling to work out how to merge sketches

Actually,

Most ALL examples have a single void loop()

Merging sketches means that in essence you put stuff from all the loop()s into the loop() of your final sketch, and ditto with setup(). Also do that for all the stuff that usually sits above setup(), checking that you don't (eg) use the same name for more than one variable, or use the same pin number for 2 things, and don't duplicate #include's and so on.

But the specifics of merging sketches depend on the actual sketches and what you want the final sketch to do. If (for example) you try to merge blink with other sketches, you'll have a problem since blink is blocking code. Sometimes it may not even be feasible to "merge" sketches, and a whole do-over may be required.