In programming, a very important concept to understand is the loop. Loops allow you to repeat a sequence of instructions until a condition is met. In Tello EDU the loop command is found in the "control" block. We will use this block to repeat a series of moves to complete the mission.
We are going to code a mission that uses each of the motion, variables and control blocks and instructs Tello to perform each of the script 2 times. Without the capability of a loop, or repeat block, the code would appear similar to Figure 2. However, by using a loop or repeat block the redundant code can be reduced similar to Figure 4.
As you can see in Figure 2 there are several blocks that repeat multiple times and if you wanted to continue the zig zag pattern the code would become unmanageably long.
If we refer to Figure 2 a repeating pattern can be identified therefore we can use a repeat control block to reduce the physical amount of code that is needed to be scripted.
Flowcharts can be an excellent way to visually represent the code and identify if the script will work. Figure 3 demonstrates the possible sequence for level 1.4 of the Tello Edu app.
The flowchart was made using a flowchart generator: https://www.draw.io/
A control block such as an if/else statement can be used to reduce the amount of code further, Figure 4 demonstrates one way in which this code can be written however, there are various alternatives. Can you design and create a script that completes the course with the same or fewer blocks than figure 4. This program is not the most efficient code and only achieves 2 out of 3 stars.
A control block such as an if/else statement can be used to reduce the amount of code further, Figure 5 demonstrates another way the code can be written using the if/else statements this code gets 3 out of 3 stars.