Snap Mission 5: Gyro Turn
This mission is to fly the CoDrone in a square using the gyro to make sure that it makes proper turns to make a square.

Neutral above studio shot

Summary

We can have the CoDrone fly in a square using the gyro. We will have the CoDrone take off then turn towards 0 degrees to start with. Then it will fly forward and stop. Next we will turn towards 90 degrees and then go forward. We will repeat this until we are back where we started. We will use the turns we learned in lesson 13. This makes it so that even if one turn is a little off, the next turn will still turn to the correct position.

The movements will look like this:

If you remember from lesson 13 a gyro turn looks like this:

 

We will use this code to control the turning of the CoDrone. Before this turn though we need to have the CoDrone take off, and then once it has finished the turn we will have it move forward.

This will have the CoDrone takeoff and turn towards 0 degrees. After it turns to the correct direction it moves forward for 2 seconds. Then we need to add in the turns and movements for all of the next movements.

 

Each time it turns we need to adjust the target value by 90 degrees. This also means we nee to change the values for our if statements so that they are going from the target angle to 180 degrees farther.