a1tD000000882Y0IAI

Course: Programming with CoDrone Lite
8-Improving your control with CoDrone Lite

  • 4-7 grade
  • Beginner

Lesson Description:

Students have been using their CoDrone autonomously for previous lessons --- they have been creating and uploading programs so the CoDrone can perform specific flight commands. In this lesson, they will learn how to use Snap to create and run a remote control program to control their drone’s speed, and then create and run another program to play Flappy Bird. In addition, we students will learn how to program the CoDrone's eyes to let you know when the battery is low.

Objective:

  • Explain the differences between an autonomous robot and a remote controlled robot and the benefits of using either
  • Create and run a remote control program in Snap that includes conditionals, loops, and variables
  • Create and run a remote control program in Snap that can complete an obstacle course
  • Create and run a program in Snap that checks the CoDrone’s batteries and uses the LEDs as a battery percentage display
  • Create and run a program in Snap that lands the drone safely when the battery is getting too low

image description

Lesson Modules


Teaching Tips:

  • Let students know that at this point, they have been using their CoDrone as an autonomous robot, but with this lesson, they will be using a remote control. What do they think that means? Next, show them the video below and ask what they think an autonomous or remote controlled robot is based on what they just saw. Also ask the benefits to having either one. What would be a good situation to have an autonomous or remote controlled robot?

Video: Case IH Autonomous Concept Vehicle

  • Ask students to think of all the electronics that they use and how they know that their battery is low or dead on each of them. If they are stuck, give an example (if they have a phone or laptop on them, they can check for a battery icon). Next, ask them how they can tell if their CoDrone is running out of battery, and if needed, pass out CoDrones so they can look. Tell them that they will be programming a part of their drone to serve as a battery display.


What do you think is an autonomous or remote controlled robot? What would be a good situation to have an autonomous or remote controlled robot?


Teaching Tips:

  • Ask students to use pseudocode to explain to a partner how they programmed their drone for the speed variable challenge in Snap using both their own words and the appropriate academic language.
  • Ask students to use pseudocode to explain to a partner how they programmed their drone to either display battery percentage or land safely after a low battery in Snap using both their own words and the appropriate academic language.

  • We found a bug just recently that is caused by the request block, specifically for BATTERY_PERCENTAGE. It checks the battery percentage, but continues checking (behind the scenes) even after you've stopped and deactivated the block. So if you see that the BLE board is flashing multi-color even when you aren't actually trying to send commands to it, that means that is happening. The kicker is once you try to run any other code while that bug happens (i.e. the board is still blinking multi-color even when you aren't running commands), it will overload and shut the board off, which obviously causes the CoDrone to disconnect.

    The company is currently fixing that bug so the next version of the Chrome app doesn't have that bug. For now, the only way to stop the background request at the moment is to restart Snap. 

Challenge

Activity: Fast and precise flying

Use what you learned in this lesson and in the variables lessons to allow your CoDrone to fly at two speeds! Use the remote control to have one key for high speed and another key for low speed.

Challenge rules:

  1. Create a variable to keep track of your speed.
  2. Your CoDrone should be able to fly at two speeds: high (for a drone race) and low (for obstacles or landing on precise targets)


Activity: Low battery landing

Have your CoDrone safely land when the battery is too low!

Challenge Rules:

  1. Make a code that will land the CoDrone when the battery is less than 20%.
  2. Crashing does not count as a safe landing!

Teaching Tips:

Customization

If you want to make this mission more difficult, we have ideas!

  • Use hoops or tunnels to fly through to get to the landing zone.
  • Increase the pitch speed to increase the difficulty.

Sample code

Not sure where to start? We have a sample code!

In this code, the CoDrone takes off, and until the program ends, the CoDrone moves forward. If the up key is pressed, the CoDrone will throttle up. If the up key is not pressed, the CoDrone will start to fall down. You can increase the difficulty by increasing the values for pitch and throttle. 100 is the highest!

Extra Challenge

Flappy Drone

The goal of the Flappy Drone mission is to fly your CoDrone over and under different obstacles. However, there are some twists!

  • You can only control your CoDrone's throttle.
  • Your CoDrone is always moving forward.
  • When the up arrow is pressed, the drone will fly up, but if it's not pressed, the drone will start to fall.

Don't worry --- you can program a kill switch!

How to play

1. Setup

  • Set up a starting zone and a target area. Doorways are great for this! 
  • Set up some obstacles to fly over and under. Boxes, tables, chairs, and propped up broomsticks are all great obstacles, but get creative!

2. Fly

  • Begin by placing your CoDrone in the starting zone. When you're ready, start your code and try to make it to the end without crashing into anything!

3. Modify

  • If your CoDrone isn't going up high enough or is going up too much, or if it's barely going forward or going too fast, go back to your code and change the numbers!

Rules

  • If there are multiple competitors, take turns!
  • All parts of the CoDrone that are touching the ground must be within the landing zone for it to count.
  • Each competitor gets the same set time to complete the challenge.
  • The first competitor to successfully land in the landing zone wins!


Teaching Tips:



What are some benefits to using an autonomous robot? What are some benefits to using a remote-controlled robot?


Explain one of your programs using pseudocode.


What other features on your CoDrone could work as a battery display? How would you program them to show battery percentage?