1.
8: Remote Control
So far you've only done autonomous programming with your CoDrone EDU --- once
you upload the program, it takes off, flies, and lands on its own. You get to move on
to a remote control now --- you'll program your computer keys to control the
CoDrone EDU once it's up in the air!
This lesson works with:
CoDrone EDU CoDrone EDU Blockly
(JROTC ed.)
beginner Blockly CDE CDEJ
keyboard programming remote control
Grade level: Approx. time required:
6 - 12+ 30 - 45 mins
Step 1
Getting Started
Make sure that your drone is connected with Blockly before starting the lesson! If
you are unsure of how to connect, go back to the first lesson to review!
Step 2
Keyboard Input
You may be wondering how to use the keyboard to control CoDrone EDU. In this
activity, you will learn how to use conditionals to control your LED and flight
movements. Start your program with the light off so you can turn it on later with
the space bar.
Step 3
Forever Loop
Since you want your program to constantly check if you are pressing a key, you
will need to implement a forever loop. For this example, use a repeat loop block
and connect a code is running block from the “Status Checkers” menu.
Step 4
Conditional
Now it’s time to check for keyboard input! Remember that when a program
needs to make a decision, you should use a conditional statement.
Go to the “Logic” menu and grab a conditional block.
In the “Events” menu, grab a when backspace key press block. From the
drop-down menu, select “spacebar”.
If the space bar is pressed, turn on your drone LED to any color.
Step 5
More Keys
If you want to check for multiple key presses, you will need to include an else if
statement for each new key. Add five new else if statements:
when up key press
when down key press
when left key press
when right key press
when “L” key press
Step 6
Adding Flight Commands
Now add flight commands! Add in the flight directions that correspond to the
arrow keys. For “L”, land the drone.
Step 7
Add the Take-Off
Don’t forget the take off block! This block should go before the while loop. If it’s
inside the while loop, the drone will keep sending the takeoff over and over
again.
Step 8
Challenge
Challenge: Reverse Controller
For this challenge, let’s challenge your mind. Write a keyboard controller with all
the controls reversed. For example, the up key will move the drone backward
and the down key will move the drone forward.
Build an obstacle course and try to fly to the finish line using your reverse
controller. If you need to, adjust the values of the delays and add more keys for
more functionality!
Step 9
Lesson Complete
In this lesson, you learned how to program your very own remote using all the
blocks you have learned about so far. You also had the chance to design your
own obstacle course to test your flight skills with your custom controller!