Skip to main content

From commands to missions

You can already take off, move, and land. Now you’ll combine blocks into smart, flexible programs using the ideas real programmers use every day: loops, variables, decisions, operators, broadcasts, and custom blocks. Work through these programs in order. Each one adds exactly one new idea, and each ends with a challenge to make it your own. That’s four-plus hours of building - pick up wherever your class is.
A ladder of coding concepts building from sequence up to custom blocks

Each program climbs one rung up the coding ladder - loops, variables, decisions, and beyond

Every program below flies the drone. Run in a clear space, keep people back, and keep the 🔴 stop and 🚫 no-entry buttons in reach.

Program 1 - Fly a square with a loop

Instead of writing “move, turn” four times, use a repeat loop. This is the single most useful pattern in drone coding.
AT-66BL Control category blocks including repeat and forever

Control blocks: repeat, forever, if-then, wait until, and repeat until

Start and take off

Add when 🏳 clicked, then take off.

Add a repeat loop

From Control, drag a repeat [10] block and change it to 4.

Fill the loop

Inside the loop, add horizontal move [Forward] [50] cm speed [1], then turn [Right] [90] degree speed [1].

Land

Snap land below the loop.

Challenge

Change the repeat to 3 and the turn to 120° to fly a triangle. What repeat count and turn make a hexagon? (Hint: 360 ÷ sides.)

Program 2 - One number, any shape (variables)

A variable is a named box that holds a value. Store the number of sides once, and the whole program adapts.
AT-66BL Variables category blocks

Variables blocks: make, set, and change your own values

Make a variable

Click Make a Variable and name it sides.

Set it

After take off, add set [sides] to [4].

Use it in the loop

Use repeat [sides]. For the turn, drop an Operators division block in and build turn Right (360 / sides) degree.
Now change sides from 4 to 6 and the same program flies a hexagon. One change reshapes the whole flight - that’s the power of variables.
Diagram showing how changing one variable value changes the flown shape

Change one variable, get a totally different shape - the same code flies them all

Challenge

Add set [size] to [50] and use it for the move distance too. Now one program flies any shape at any size.

Program 3 - Loops inside loops (a spiral tower)

Put a loop inside a loop to build patterns. Fly a square, rise a little, repeat.
The inner loop flies a square; the outer loop stacks three squares into a climbing tower.

Challenge

Make each layer smaller than the last using a size variable and change size by -10 each loop.

Program 4 - Make it decide (if-then + operators)

An if-then block lets the drone choose what to do. Combine it with Operators to build a condition.
AT-66BL Operators category blocks

Operators blocks: random, comparisons, and logic

Use pick random so every run is different:
Each lap the drone flips a coin and turns left or right - the path is a surprise every time.

Challenge

Use pick random 1 to 4 and multiply by 90 to pick a random turn each time.

Program 5 - Time a routine (Sensing + timer)

The timer reports seconds since the program started. Pair it with a loop to run for a set time.
AT-66BL Sensing category blocks

Sensing blocks: timer and reset timer

The drone loops its routine until 10 seconds have passed, then lands - no matter how many laps it managed.

Challenge

Show the timer on screen with show variable, and make the drone do a different move every 3 seconds.

Program 6 - Two scripts talking (broadcast)

Broadcast lets one part of your program trigger another. This keeps big programs organized.
AT-66BL Events category blocks

Events blocks: broadcast and when I receive

The main script handles take off and land; the “dance” script handles the moves. Send dance whenever you want that routine.

Program 7 - Build your own block (My Blocks)

Package a routine into one custom block you name yourself. This is how pros keep code readable.
AT-66BL Make a Block dialog

Make a Block - name your own reusable command

Make a Block

In My Blocks, click Make a Block and name it square. Click OK.

Define it

Under the new define square hat, put the four blocks that fly a square.

Use it

Now your main program can just call square - as many times as you like.
Great programmers build in small, tested steps. Get a simple version flying, run it, then add one new feature at a time. If it breaks, you know exactly which change did it.

Instructor cheat sheet

Check for a when 🏳 clicked hat at the top of the stack, and confirm the drone is still paired (Bluetooth icon).
Fly slower (lower the speed), use larger distances, and start with a fully charged battery. Indoor drafts and low battery both cause drift.
A repeat until needs a condition that eventually becomes true. Test the condition with show variable or a shorter timer.
Turn each challenge into a quick “show me” - students fly their version for the class. Fast feedback keeps everyone building.
You built programs using a loop, a variable, an if-then decision, the timer, a broadcast, and a custom block, and you can explain what each one adds.

Next: the capstone project

Design, code, and present your own drone mission.