Lift-Off with CodeX - Mission 6: Life Support
Life Support
Astronauts need air too. Students wire up a 360 continuous servo and a switch, then write code that spins the fan clockwise and counter-clockwise to keep air circulating through the spacecraft.
Overview
Astronauts need air too! Being on another planet can get lonely sometimes, and it doesn't matter how safe the crew is if they can't breathe. Ensuring consistent air quality is key to the success of this mission. Students use a 360 continuous servo to make sure air circulates throughout the spacecraft.
This project is a great opportunity to connect life science with computer science. Students can discuss the impact of poor air quality on human health while they build the system that fixes it. Along the way they meet exp.pwm_out(), integer division, and nested if statements that move the program from one state to the next.
🎯 Mission Goal: Students write code to simulate air circulation.
Learning Targets
- I can set the analog period on the 360 servo.
- I can make the servo spin clockwise and counter-clockwise.
- I can start and stop the servo using a switch.
Key Concepts
- The duty cycle determines the speed and direction of the 360 servo.
- A program can use "states", or phases, to determine what happens next.
- Nested if statements let the program transition from one state to the next.
Assessment Opportunities
- Check for Understanding in CodeSpace
- Mission 6 Assignment
- Make a chart of percent, speed, and direction of the servo, based on observation using code
- Exit ticket - draw a diagram of the finite-state machine for this mission
- Submit and/or check the LifeSupport program
- Journal entry on their learning experience
Success Criteria
- Connect a servo with a servo horn to the CodeX.
- Use a function call to control the servo's speed and direction.
- Control the servo with a switch.
Digital Resources
Classroom Materials
- ▸Laptop/computer with the Chrome browser
- ▸CodeX and connecting cable
- ▸360 continuous servo and one servo horn
- ▸Switch peripheral
Real-World Applications
Extensions & Cross-Curricular
🔤
Vocabulary
▾
🐍
New Python Code
▾
CYCLE * percent//100
📐
Standards
▾
CSTA Standards - Grades 6-8
CSTA Standards - Grades 9-10
CSTA Standards - Grades 11-12
- Students need a computer or laptop with the Chrome web browser.
- Make sure students can successfully log in to make.firialabs.com.
- Pull one servo horn per servo and set the extra horns and screws aside before you hand out the peripherals.
- Connect a servo and run it yourself once so you can demonstrate the clockwise and counter-clockwise spin.
- The wires on the servo are slightly different colors than the other peripherals. Brown corresponds to black, and orange corresponds to yellow.
- Students only need one of the plastic pieces (horns) included with the servo. You may want to remove the others, along with the screws, before distributing the peripherals.
-
Integer division
//is used in this mission. Some practice problems are included in the assignment, and you can cover the operation in more detail if your students need it. - You may need to discuss duty cycles to help students understand the servo's analog control signals. A duty cycles table works well as a guide, and you can read more about servos and duty cycles at PCB Cadence.
- The goal validator can be particular on some objectives. Python does not distinguish between single and double quotes, but the verifier sometimes will. If a student's code is having trouble verifying on Objective 4, check the quotes first.
- Extensions and cross-curricular projects are included to enhance the concepts in the mission. A remix is not explicitly planned here, but you can add one as an option for extra learning. A remix and assessment follows Mission 6.
Lesson Outline
Students access prior knowledge by answering the pre-mission questions in the assignment doc.
- Ask: "A spacecraft is sealed shut. Where does the air come from, and what happens to it if nothing moves it around?"
- Ask: "Name something in your house with a motor that has to run at different speeds. How does it know which speed to use?"
Front-load the hardware and the two new ideas before students start typing.
- Show the 360 continuous servo and a servo horn, and point out that brown is ground and orange is signal on this peripheral.
-
Introduce
exp.pwm_out(exp.PORT0, frequency=20)and explain that the duty cycle sets both speed and direction. -
Walk through integer division
//with two or three quick examples on the board. - Sketch a simple finite-state machine on the board: off, spinning one way, spinning the other. Name the transitions out loud.
Students work through the mission objectives in CodeSpace, taking notes and answering questions in their assignment doc as they go.
- Attach a horn to the servo and connect the servo to the CodeX, checking the wire colors.
-
Build LifeSupport, setting up the servo with
exp.pwm_out(exp.PORT0, frequency=20). - Write a function that takes a percent and sets the duty cycle, then test values that spin the fan clockwise and counter-clockwise.
- Add the switch and use nested if statements to start, stop, and reverse the fan as the program moves between states.
- Complete the Check for Understanding in CodeSpace.
Bring the class back together to lock in states and transitions.
- Ask: "What percent values made the fan spin clockwise, and what values reversed it? Where was the stopping point?"
- Ask: "What states does your program have, and what has to happen for it to move from one to the next?"
- Ask: "Why do we need nested if statements here instead of one long list of separate ifs?"
Students answer the reflection question in the assignment doc, add a journal entry about their learning experience, and submit.
Use the Mission 6 Review Questions or the Mission 6 Review Kahoot! through whichever method you prefer, class discussion, Kahoot!, or an LMS quiz.