Lesson 4. I code cards with a coding drone (2)




[Outline]


In this lecture, I am going to try coding a card that makes a pattern flight with a coding drone.
Pattern flight refers to flying in a certain form of route, such as triangles, squares, circles, and spirals.
This pattern flight is used when drones are utilized in various industries such as filming, agriculture, and surveying. Here, we are going to do a square pattern flight.

And in the pattern flight, some patterns are repeated because the route is standardized.
In this case, you can simplify your code by using loops when coding.
In this lesson, we will learn what looping statements are and how to use them through pattern flight.


[Thinking of code]


The square pattern flight sequence repeats 1 space forward and left turn 4 times.

repeat 4 times
① advance 1 space
② turn left


So let's think about how to write the code to fly like the one above. First, let's create the code without using a loop.


1. Rectangular pattern flight (without loops)

action sequence
Start → Takeoff → (Go forward 1 space → Turn left 90 degrees) x 4 → Landing → End
card order


Next, let's create code using loops. First, let's figure out what a loop is.

easy-to-understand coding

loop

A loop is one of the main grammars of coding and is used to repeat the same or similar commands. By using loops, it not only reduces the length of the code, making it easier to understand, but also allows for more diverse and efficient coding implementations.

There are several types of loops, such as repeating until a specific condition is satisfied, repeating the specified number of times, and repeating infinitely.


There are a total of 4 loops that are basically provided in card coding.


① infinite loop
② 2 repetitions
③ 3 repetitions
④ 4 reps
무한반복 2회반복 3회반복 4회반복


Here's how to use the loop:


4회반복
☞ Repeat command is input by reading the command cards to be repeated between the repeat start card (infinite repeat, repeat 2 times, repeat 3 times, repeat 4 times) and the end of the repeat in sequence.


Now, let's make a square pattern flight code using a loop. Compare how it differs from the code without the loop.


2. Flying a square pattern (using loops)

action sequence
Start → Takeoff → (Go forward 1 space → Turn left 90 degrees) x 4 → Landing → End
card order
사각형 패턴 비행(반복문 사용)


You can see that it's a lot more simplified than the code without loops.
When performing the action of repeating a specific command like this, using a loop can make the code more concise and easier. Now let's run the code.



[Coding and running]


1. Rectangular pattern flight (without loops)



Step 1 - Prepare your coding card


사각형 패턴 비행(반복문 미사용) 1단계
Prepare the coding cards necessary for card coding.
※ “Card coding mode” card omitted

Step 2 - Arrange the coding cards


take off → (Go forward 1 space → Turn left 90 degrees) x Repeat 4 times→ landing
사각형 패턴 비행(반복문 미사용) 2단계
Arrange the cards in the order of action. Don't forget that there are always “Coding Start” and “End Coding” cards at the beginning and end of coding!

Step 3 - read the coding card


사각형 패턴 비행(반복문 미사용) 3단계
Put the battery in the coding drone, turn it on, and read the coding card.
Place the coding drone in the correct position to read the coding card (make sure the guard pattern of the drone and the guard pattern of the coding card match) and press the operation button once in the order of the card to read the card.
If you read the card incorrectly in the middle, start over from the beginning (=“Start coding” card).


Step 4 - run the code


사각형 패턴 비행(반복문 미사용) 4단계1사각형 패턴 비행(반복문 미사용) 4단계2
Place the coding drone on a flat surface with no people or obstacles nearby.
And press the action button twice in succession to execute the coding.
After about 3 seconds, the coding drone automatically executes the coded command

※ After pressing the action button, immediately move away from the drone by a safe distance. (Beware of safety accidents!)


Next, try running the code using the loop.


2. Rectangular pattern driving (using loops)



Step 1 - Prepare your coding card


사각형 패턴 비행(반복문 사용) 1단계
Prepare the coding cards necessary for card coding.
※ “Card coding mode” card omitted

Step 2 - Arrange the coding cards



take off → (Go forward 1 space → Turn left 90 degrees) x Repeat 4 times→ landing

사각형 패턴 비행(반복문 사용) 2단계
Arrange the cards in the order of action. Don't forget that there are always “Coding Start” and “End Coding” cards at the beginning and end of coding!

Step 3 - read the coding card


사각형 패턴 비행(반복문 사용) 3단계
Put the battery in the coding drone, turn it on, and read the coding card.
Place the coding drone in the correct position to read the coding card (make sure the guard pattern of the drone and the guard pattern of the coding card match) and press the operation button once in the order of the card to read the card.
If you read the card incorrectly in the middle, start over from the beginning (=“Start coding” card).


Step 4 - run the code기


사각형 패턴 비행(반복문 사용) 4단계1사각형 패턴 비행(반복문 사용) 4단계2
Place the coding drone on a flat surface with no people or obstacles nearby.
And press the action button twice in succession to execute the coding. After about 3 seconds, the coding drone automatically executes the coded command.

※ After pressing the action button, immediately move away from the drone by a safe distance. (Beware of safety accidents!)


[Organize]


In this lecture, I tried to fly a square pattern by coding a card with a coding drone.
And I also learned that the same repeating pattern can be coded more easily by using a loop.
Now, think about how to code other patterns besides squares, and try coding the cards and flying them.

1) Pattern flight refers to flying in a certain form of route, such as triangles, squares, circles, and spirals.
2) Because pattern flight has a standardized route, there are cases where some patterns are repeated, in which case you can use a repeating card.
3) Using loops in coding can make your code more concise, making it easier to code.



Coding with a coding drone (English)

  1. Make friends with Coding Drone!
  2. Let's fly a coding drone
  3. I code cards with a coding drone (1)
  4. I code cards with a coding drone (2)
  5. I code cards with a coding drone (3)
  6. Motion coding with a coding drone
  7. Block coding with a coding drone(1)
  8. Block coding with a coding drone(2)

Modified : 2021.7.30