a1tD00000087wjZIAQ

Course: Programming with CoDrone Lite4-Conditionals with CoDrone Lite

• Beginner

Lesson Description:

Conditionals will be part of almost every program that a student makes to fly their CoDrone. This lesson will cover what conditionals are and how they work, and then students will create and run their own programs using conditionals. In addition, students will include conditionals in their programs and create a program so their drone can decide where to land.

Objective: Explain what a conditional is, how it works, and why it is used. Create and run a program in Snap that includes conditionals, loops, and variables, allowing the drone to decide which pad to land on.

Teaching Tips:

• Tell students that conditionals in programming consist of if-statements, else-statements, and if-else statements. Have them talk in groups and try to come up with what one of those terms means. Examples work too! Show the following video and ask for observations, thoughts, and questions:

Video: Bill Gates Explains IF & IF/ELSE Statements

The link to the video is also in the ClassView menu so you can project it to the class.

What is a conditional, and how is it used in programming?

Give an example of a conditional from everyday life.

Teaching Tips:

• At this point, most students have a favorite card game. As a group, they will need to write directions and rules to the game using only if, if-else, and else statements. This can be done as pseudocode or in something more visual like a flowchart. When time is called, have the group leave their instructions with the game and then rotate to where the group to their left was sitting. They will then need to play the game in front of them using the conditional directions and rules that were left.
• Which groups were successfully able to play their game? What helped them out? Which groups were not successfully able to play the game? What problems did they run into? What do they think a computer or robot would do in that situation and how would they fix it?

Teaching Tips:

• Ask students to use pseudocode to explain to a partner what they did in their own words and the appropriate academic language.
• For an extra challenge, keep moving the landing pads farther apart so students can modify their code to change their distance (this can be done with variables!)
• Having problems with the flight? This can be caused by an imbalance in the motors. Check out this page.

Challenge

You get a challenge! Create another if statement where if your variable is greater than 14, it will be set to 11. If your variable not greater than 14, it will be set to 32.

Not sure what to do? You can start with your current code, including the else if statement. You might need to use another one!

Extra Challenge*

*(Check "Explore" of "Flight movements with CoDrone Lite")

Activity: Decide

Have your CoDrone land on two different landings pads! No pressure, but you can only change the value of your variable by 1.

Challenge Rules:

1. The course should be set up in a T shape, with the start at the bottom of the T and the landing pads at the top ends of the T.
2. The landing pads should be the same distance from the starting point.
3. Your CoDrone should travel up the middle of the T, turn towards a landing pad, and then fly to and land on the landing pad.

Teaching Tips:

Why would a programmer use conditionals in their code?

Explain either your decision program using pseudocode.

Did you have any problems running either of your codes? If so, what did you do to fix them? What did you learn?