Lift-Off with CodeX - Mission 8: Prepare Lander!

Mission 8 Lesson Plan

Prepare Lander

Getting to Mars is the easy part. Students build a complete ground sensing system out of several peripherals and write code that walks the spacecraft through the phases of a landing.

⏱ 60-90 min 🎯 Grades 4-12+ 💻 CodeSpace 📱 CodeX 🔌 Peripherals Kit 🐍 Python
View Lesson Outline
📋

Overview

Another small step for mankind. Getting safely to Mars is the easy part, landing safely is where the fun starts. In this mission students put together a complete ground sensing system from several peripherals at once, then write the code that decides what the spacecraft does at each point in the descent.

The object sensor is the new piece of hardware, and it takes a screwdriver and a ruler to adjust it to the manufacturer's specification. Once it is dialed in, students combine it with the microswitch, the NeoPixel ring, and the 180 positional servo. Phases, or states, return from Mission 7, and here they are doing more work: the state variable controls the lighting and the servo, and two different input peripherals move the program from one state to the next.

🎯 Mission Goal: Students write code to simulate landing the spacecraft.

🎯

Learning Targets

  • I can connect and adjust the object sensor.
  • I can change the position of the 180 servo.
  • I can use the object sensor to trigger an event.
  • I can use the microswitch to trigger an event.
  • I can use states and a state variable to control the NeoPixel ring and 180 servo.
💡

Key Concepts

  • A variable that represents the state, or phase, allows the program to remember information about events.
  • Different input peripherals can be used in the same program to change the state and trigger events.

Assessment Opportunities

  • Check for Understanding in CodeSpace
  • Mission 8 Assignment
  • Explain the steps, or how the set_lighting() function works
  • Exit ticket - draw a diagram of the states of the program
  • Submit and/or check the PrepareLander program
  • Journal entry on their learning experience
☑️

Success Criteria

  • Connect an object sensor to the CodeX and adjust it to the manufacturer specifications.
  • Use the object sensor to trigger an event.
  • Use the microswitch to trigger an event.
  • Use a variable for states to control the NeoPixel ring and 180 servo.
🧰

Classroom Materials

  • Laptop/computer with the Chrome browser
  • CodeX and connecting cable
  • Small Phillips screwdriver
  • Small ruler with millimeters
  • NeoPixel ring
  • Object sensor
  • Microswitch
  • 180 positional servo and servo horn
NeoPixel ring peripheral with eight addressable RGB LEDs arranged in a circle Object sensor peripheral board for the CodeX with an infrared emitter and detector and an adjustment screw Microswitch peripheral board for the CodeX with a lever arm and the G, V, S labels 180 degree positional micro servo with a three-wire cable Divider connector used to plug two peripherals into one CodeX port
🌍

Real-World Applications

🤖Robots and autonomous cars use object sensors for line detection and object detection.
🛑Impact avoidance systems watch for something in the way and stop before they hit it.
🚪Automatic doors, hand dryers, and faucets all use a version of the same sensor.
🖨️Printers and paper handlers use object sensors to know whether a sheet made it through.
💬Have students discuss where and how an object sensor might be used in common items and appliances.
🚀

Extensions & Cross-Curricular

ChallengeUse a CodeX button as an abort button.
ChallengeDisplay the current state on the display screen.
ChallengeAdd a fourth state, before init, that requires some crew action.
ChallengeUse the CodeX buttons as a check-in for each crew member, indicating they are ready for landing.
ChallengeAdd an alert sound when landing.
ChallengeUse the CodeX buttons as communication devices, where a button press indicates a phase to mission control.
ChallengeOnce landed, use the CodeX's ambient light sensor to adjust the solar panels.
Lang ArtsHave students compare and contrast this mission to previous missions.
ScienceSeveral missions have now used the finite-state machine model. Discuss other places states show up in science, such as the life cycle of an organism.
ScienceTeach a lesson on how the object sensor works.
🔤

Vocabulary

Pull - A property that can be changed when setting up an input peripheral. It determines the default value of a pin when nothing is connected. The pull can be set to "up" to move a weak pull toward 3 volts.
🐍

New Python Code

sensor = exp.digital_in(exp.PORT1, pull=digitalio.Pull.UP)Changes the pull property to "up" so the weak signal is pulled toward 3 volts, or "high".
📐

Standards

CSTA Standards - Grades 6-8

2-CS-02 2-CS-03 2-DA-08 2-AP-10 2-AP-11 2-AP-12 2-AP-13 2-AP-14 2-AP-16 2-AP-17 2-AP-19

CSTA Standards - Grades 9-10

3A-CS-03 3A-DA-11 3A-DA-12 3A-AP-13 3A-AP-15 3A-AP-16 3A-AP-17 3A-AP-18 3A-IC-26

CSTA Standards - Grades 11-12

3B-CS-02 3B-DA-05 3B-DA-06 3B-DA-07 3B-AP-10 3B-AP-14 3B-AP-15 3B-AP-16 3B-AP-17 3B-AP-21 3B-AP-22 3B-AP-23
📝
Preparing for the Lesson
  • Students need a computer or laptop with the Chrome web browser.
  • Make sure students can successfully log in to make.firialabs.com.
  • Gather enough small Phillips screwdrivers and millimeter rulers for students to share. They are needed to adjust the object sensor.
  • Adjust one object sensor yourself before class so you know how far the screw has to turn and what the indicator light does when it detects something.
  • Pull one servo horn per servo and set the extra horns and screws aside before you hand out the peripherals.

🧑‍🏫
Teacher Notes
  • The screwdriver and small ruler are used to adjust the object sensor. Students measure the detection distance and turn the screw until the sensor triggers where the manufacturer says it should.
  • This is the biggest build in the pack so far, with four peripherals in one program. Have students connect and test each one on its own before they combine them.
  • The pull property is new here. If a digital input reads as triggered when nothing is connected to it, that is what pull=digitalio.Pull.UP fixes.
  • States return from Mission 7 and carry more weight in this program. A state diagram on the board, drawn before anyone types, saves a lot of debugging later.
  • Extensions and cross-curricular projects are included to enhance the concepts in the mission. You can use the extensions to extend students' programming experience. A remix is not explicitly planned here, but you can add one as an option to give students additional learning. The next remix comes after Mission 9.
🗺️

Lesson Outline

🗣️Warm-up / Hook

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

  • Ask: "Getting to Mars is one problem. Landing on it is another. What does a spacecraft need to know on the way down?"
  • Ask: "How would a machine know it has touched the ground? What could it measure to be sure?"
Teaching tip: Ask the class to narrate a landing out loud, step by step, then write their steps on the board as phases. That list is the state diagram they will code, and they came up with it themselves.
📖Introduce the Mission

Front-load the new hardware and the state model before students start typing.

  • Pass around the object sensor. Point out the infrared emitter and detector, and the adjustment screw that sets the detection distance.
  • Demonstrate the adjustment with a screwdriver and a millimeter ruler so students see what "manufacturer specification" means in practice.
  • Introduce the pull property and show what pull=digitalio.Pull.UP does to a digital input with nothing connected to it.
  • Sketch the states of the landing on the board, along with the input that moves the program from each one to the next.
Teaching tip: Two different peripherals drive the state changes in this program, the object sensor and the microswitch. Make that explicit up front so students know which sensor they are watching in each phase.
💻Coding Time

Students work through the mission objectives in CodeSpace, taking notes and answering questions in their assignment doc as they go.

  1. Connect the object sensor to the CodeX and adjust it with the screwdriver and ruler until it triggers at the right distance.
  2. Read the object sensor in code and use it to trigger an event.
  3. Connect the microswitch and use it to trigger a second event.
  4. Write the set_lighting() function to fill the NeoPixel ring with a color for the current phase.
  5. Build PrepareLander using a state variable to control the NeoPixel ring and the 180 servo through each phase of the landing.
  6. Complete the Check for Understanding in CodeSpace.
Teaching tip: Have students test each peripheral by itself before wiring the whole system. When four things are plugged in at once, a bad connection looks exactly like a bug in the state logic.
Teaching tip: If a sensor seems to fire on its own, check the pull setting and the adjustment screw before rewriting any code.
🧑‍🤝‍🧑Class Debrief

Bring the class back together to lock in states, transitions, and the role of each sensor.

  • Ask: "What are the states in your program, and what has to happen to move from one to the next?"
  • Ask: "Which sensor triggers which event, and why does each one fit its job?"
  • Ask: "Walk me through what set_lighting() does, step by step."
Teaching tip: Use the exit ticket here. Having students draw their own state diagram shows quickly who is tracking the phases and who is just reacting to sensor readings one line at a time.
✏️Wrap-up & Review

Students answer the reflection question in the assignment doc, add a journal entry about their learning experience, and submit.

Use the Mission 8 Review Questions or the Mission 8 Review Kahoot! through whichever method you prefer, class discussion, Kahoot!, or an LMS quiz.

Teaching tip: Finite-state machines have now shown up in several missions. If students are comparing this one to earlier projects for the language arts extension, that is the thread worth pulling.