Fly with Python - Mission 3: Pre-Flight Check

Mission 3: Pre-Flight Check | Fly with Python
Mission 3 Lesson Plan

Pre-Flight Check

Students program CodeAIR's lighting and sound systems, using loops, delays, and pixel LEDs to run a full pre-flight check sequence.

⏱ 60-90 min 🎯 Grades 6-12+ 💻 CodeSpace 🚁 CodeAIR 🐍 Python
View Lesson Outline
📋

Overview

Mission 3 takes students deeper into CodeAIR programming as they learn to control the pixel LED lighting system and speaker. Students use loops and delays to animate lights and compose sound sequences, culminating in a full pre-flight lighting check using the international Aircraft Position Lighting standard. This mission introduces fundamental programming concepts, including loops, constants, and iteration, through hands-on drone code.

🎯 Mission Goal: Students will learn how to conduct a pre-flight check of CodeAIR by programming its lighting system and speaker.

🎯

Learning Targets

  • I can control CodeAIR's lighting system.
  • I can program the speaker to add sounds.
  • I can program the onboard lighting system to show the colors of the international Aircraft Position Lighting scheme.
💡

Key Concepts

  • To slow down computer code, which runs very quickly, you need a delay. In Python, use a sleep() function to slow down the action.
  • You can use editor shortcuts to copy and paste code.
  • A loop, like the while True: statement or for loop, repeats a block of indented code.
  • CodeAIR has a speaker that produces beeps in different frequencies and durations.
  • CodeAIR has 8 pixel LEDs that can light up any color. They are numbered 0-7.

Assessment Opportunities

  • Quiz after Objective 2
  • Quiz after Objective 4
  • Quiz after Objective 7
  • Complete the program CycleLEDs
  • Complete the program Melody
  • Complete the program SkyLights
  • Complete the program RunningLights
  • Mission 3 Assignment
  • Mission 3 Review Questions
☑️

Success Criteria

  • Use a loop to repeat a block of indented code
  • Use the speaker to play music
  • Control the pixel LEDs
  • RunningLights works correctly and runs without errors
  • Complete Mission 3 Assignment
🧰

Classroom Materials

  • Laptop/computer with Chrome browser
  • CodeAIR, battery and USB cable for each student or programming pair
  • Adaptor for USB cable, if needed
🌍

Real-World Applications

✈️Pre-flight checklists are required in aviation before every flight. Pilots systematically verify lights, instruments, and controls to ensure safety.
💡The international Aircraft Position Lighting standard (red, green, white) is used on all aircraft and drones worldwide to communicate orientation and prevent mid-air collisions.
🎨RGB pixel LEDs are used in consumer electronics, stage lighting, and architectural displays. The same color-mixing principles students use in this mission power everything from TV screens to stadium light shows.
🚀

Extensions & Cross-Curricular

ExtensionUse the LEDs and pixel LEDs to display a full light show. Add music using the speaker.
ExtensionHave students do a code review: select a loop to evaluate and discuss its efficiency, correctness, and clarity.
ExtensionDiscuss abstraction and how it is used in the hardware of CodeAIR.
SciencePixel LEDs use red, green, and blue lights to make colors. Research how light produces color.
MathUse math skills to plan a light show with specific timing: how long to sleep, and how long to display the lights.
Lang ArtsCompare and contrast the different types of loops.
🔤

Vocabulary

Pre-flight Checks: Going through a detailed checklist before every flight. The list includes lighting systems, safety devices, control surfaces, engines and navigation sensors.
Embedded Systems Programming: Writing code that goes in a tiny microcontroller embedded in an electronic device.
Sequence: Code that runs one line at a time, in order; sequential.
Sleep: Controlling the pace of code execution by using a delay timing tool.
While Loop: A statement that tells Python to repeat a block of code indented beneath it as long as the given condition is true.
Condition: An expression that evaluates to True or False (Boolean).
Infinite Loop: Repeat a block of code while a condition is always True and doesn't end.
Constants: Named values that don't change during program execution. Constants are usually defined at the top of program code, just below imports.
Scientific Pitch Notation: A method of specifying musical pitch by combining a musical note name (A-G) and a number identifying the pitch's octave (0-9).
RGB Color: Digital colors made up of (RED, GREEN, BLUE) light. The three colors each have a brightness from 0-255 to create many colors. The values of each color are stored in a list or tuple.
Pixel LEDs: Multi-colored LEDs that can be controlled by the CPU; also known as NeoPixels.
Range: A sequence of numbers you can iterate over. The iteration starts at the first number (or default 0) and stops one integer before the last number. seq = range(5) will iterate over 0, 1, 2, 3, and 4.
Iteration: Repeating, or iterating, through a sequence of some kind. Examples of a sequence are a range of numbers, a range of colors, a list or a tuple.
For Loop: A way to perform iteration.
Standard Navigation Lights: An international standard color scheme to indicate the orientation of the craft. Helpful for anti-collision. The lights are solid (not flashing): green for starboard side (right), red for port side (left), and white for the backend or tail.
🐍

New Python Code

from time import sleepImport the time library to access built-in timing functions like sleep.
leds.set(0, 0)Turn off an LED; use a brightness of 0.
leds.set(0, 50) / sleep(1) / leds.set(0, 0) / sleep(1)Blink an LED for 1-second intervals: turn on, wait, turn off, wait.
while True:Infinite loop: instruction ends with a colon and the indented block beneath repeats forever.
speaker.beep(frequency, duration)Play a note using CodeAIR's speaker. Example: speaker.beep(440, 200) plays at 440 Hz for 200 ms.
D5 = 587Constant definition: assign a named value (e.g., a musical note frequency) that doesn't change during the program.
leds.set_status(50)Controls the single status LED near the USB connector. Takes one argument for brightness.
COLOR_LIST = (BLACK, BROWN, RED, ...)Standard color definitions included in the codeair library from the colors module.
pixels.set(num, color)Set a pixel LED to a specific color. Example: pixels.set(0, RED) sets pixel 0 to red.
pixels.set(0, BLACK)Turn off a pixel LED. Color names are in ALL CAPS because they are from the pre-defined COLOR_LIST.
for n in range(8):For loop that iterates over 0, 1, 2, 3, 4, 5, 6, and 7: one iteration per pixel.
for color in (RED, GREEN, BLUE): /   for n in range(8):Nested loop: turns all pixels red, then green, then blue in sequence.
pixels.set(TOP_FRONT_LEFT, RED)Pixels can be addressed by position constants: BOTTOM_FRONT_LEFT, BOTTOM_FRONT_RIGHT, BOTTOM_REAR_LEFT, BOTTOM_REAR_RIGHT, TOP_FRONT_LEFT, TOP_FRONT_RIGHT, TOP_REAR_RIGHT, BOTTOM_REAR_RIGHT.
pixels.fill(WHITE, brightness=50)Turns all 8 pixels to a color at a given brightness, much shorter than setting each pixel individually.
sleep(1.0) / pixels.fill(WHITE, brightness=50) / sleep(0.02)Strobe effect: wait 1 second, flash all pixels, wait 0.02 seconds.
📐

Standards

CSTA Standards: Grades 6-8

2-CS-02 2-CS-03 2-DA-07 2-AP-11 2-AP-12 2-AP-16 2-AP-19

CSTA Standards: Grades 9-10

3A-CS-01 3A-CS-02 3A-CS-03 3A-DA-11 3A-AP-15 3A-AP-16 3A-AP-21

CSTA Standards: Grades 11-12

3B-AP-11 3B-AP-15 3B-AP-22 3B-AP-23
📝
Preparing for the Lesson
  • Ensure all CodeAIR drones are charged before class. This mission is 60-90 minutes and will require sustained use.
  • Verify USB cables and any necessary adaptors are available for each student or programming pair.
  • Consider budgeting time for multiple short check-ins during the longer coding session, as there are several programs to complete.

🧑‍🏫
Teacher Notes
  • The assignment document follows the mission and is a place for guided notes. You can print the document for students or assign it digitally through your LMS.
  • Review questions can be used as a class review, made into a Kahoot!, or used to create an exam in your learning management system.
  • Extensions and cross-curricular projects are included to enhance the concepts in the mission. A remix is not explicitly planned, but you can add one as an option. A remix is in the pacing after Mission 3.
🗺️

Lesson Outline

🗣️Warm-up / Hook

Students access prior knowledge by answering questions in the pre-mission section of the assignment doc.

Connect the mission concept to real aviation safety through a brief discussion.

  • Ask: "Why do you think pilots go through a checklist before every flight, even if they've flown the same plane hundreds of times?"
  • Ask: "What do the colored lights on an airplane or drone tell other pilots?"
Teaching tip: Show a quick image of aircraft navigation lights (red/green/white) and ask students to guess what each color means before revealing the standard.
📖Introduce the Mission

Front-load the key new programming concepts before students begin the longer coding session.

  • Demonstrate sleep(): show how code runs instantly without it, then how a delay changes behavior.
  • Introduce the while True: loop: explain infinite loops and why indentation matters.
  • Preview pixel LEDs and RGB color, briefly showing how colors mix from red, green, and blue values.
Teaching tip: This is a 60-90 minute mission with four programs (CycleLEDs, Melody, SkyLights, RunningLights). Let students know the scope upfront so they can manage their time.
💻Coding Time

Students work through four programs, building complexity with each one. As they work through the objectives, they should take notes and answer questions in their assignment doc.

  1. CycleLEDs: use sleep() and loops to cycle through the blue indicator LEDs (quiz after Objective 2).
  2. Melody: use speaker.beep() and constants to play a musical sequence (quiz after Objective 4).
  3. SkyLights: use pixel LEDs and RGB colors with for loops to create color patterns (quiz after Objective 7).
  4. RunningLights: combine all skills to program the Aircraft Position Lighting scheme (green starboard, red port, white tail).
Teaching tip: Watch for indentation errors, the most common issue with loops. Remind students that Python uses indentation to define blocks of code.
Teaching tip: Early finishers can extend RunningLights with an extension. Several suggestions are listed in the lesson plan.
🧑‍🤝‍🧑Class Debrief

Bring the class together to share RunningLights results and consolidate the big programming ideas from this mission.

  • Ask volunteers who did an extension to share their program.
  • Ask: "What is the difference between a while True: loop and a for loop? When would you use each?"
  • Ask: "Why is pixels.fill() a better choice than setting 8 pixels individually?" Connect to abstraction.
Teaching tip: Use the DroneShow real-world connection: show students images of professional drone light shows to illustrate where these pixel LED skills lead.
✏️Wrap-up & Review

Students answer the reflection question in the assignment doc and then submit.

Use the Mission 3 Review Questions through a preferred method: class discussion, Kahoot!, or LMS quiz.

Teaching tip: A remix activity follows Mission 3 in the course pacing, and you can introduce it here as an optional creative challenge for students who want to extend their light show further.