AP CSP CodeX - Mission 6: Heartbeat (Obj. 8-11)
Mission 6: Heartbeat (Obj. 8-11)
Students use a variable and float values in an infinite loop to speed up and slow down a beating heart with the CodeX buttons.
Overview
In this lesson, students finish Mission 6. They learn about the float data type, then use a variable to hold the delay between heartbeats. Pressing BTN_A adds to the delay to slow the heart down, and pressing BTN_B subtracts from the delay to speed it up. Pressing BTN_B too many times makes the delay negative, which causes an error, and students record that error in their assignment. After Objective 11 and the quiz, students go back to their code to create and call a function for adjusting the speed, and add code so the program does not crash.
🎯 Mission Goal: Students will use a variable and images in an infinite loop to create a beating heart animation.
Learning Targets
- I can apply variables to a new program.
- I can update the value of a variable using math.
- I can program using float values.
Key Concepts
- Use a variable to hold the current state of your program. In this case it is the speed of the heartbeat, or to be specific, the delay between beats.
- An infinite loop is a good way to continuously check for button presses, which lets the CodeX act on events as they occur.
Assessment Opportunities
- Mission 6 Obj 8-11 Assignment
- Heart2_functions program (final)
Success Criteria
- Create a program that shows a beating heart using an infinite loop
- Include code in the program that speeds up and slows down the heart
- Create and call a function for adjusting the speed of the animation
- Add code so the program does not crash
Digital Resources
- ▸Mission 6 Obj 8-11 Assignment
- ▸Code Solutions and Assignment Answers - Teacher Dashboard > Educator Resources button
- ▸Mission 6 Kahoot Review
Classroom Materials
- ▸CodeX
- ▸USB-C cable
- ▸Computer
Real-World Applications
Extensions & Cross-Curricular
🔤
Vocabulary
▾
count = count + 1, like a counter, but the value can be any literal number (or constant).
count = count - 1, but it can be any literal number or constant.
🐍
New Python Code
▾
📐
Standards
▾
CSTA Standards - Grades 9-10
CSTA Standards - Grades 11-12
AP CSP Framework
- The assignment is best completed digitally. Prepare the assignment to give through your LMS.
- If you have a word wall, or another form of vocabulary presentation, prepare the new terms.
- Have the Mission 6 Kahoot Review ready in case you have time at the end of the lesson.
-
Start the lesson by having students open their program from the last lesson (Mission 6 Obj 1-7),
Heart2_functions. - After Objective 11 and the quiz, students continue with the code to create and use a function. This goes beyond the instructions in CodeSpace. Students can stay in Obj. 11 or move to the sandbox. You can encourage your students to do this extension on their own, or give them the instructions for creating a function. This is all practice in preparation for the Create PT.
- If you have time at the end of the lesson, use the Mission 6 Kahoot Review.
- Refer to the lesson plans in the Python with CodeX Mission Pack Curriculum for additional challenges, cross-curricular suggestions, and additional information.
Lesson Outline
This outline gives the narration for one way to present the lesson.
Use a discussion strategy, like journaling, working at boards, selecting random students, or a form of think-pair-share.
Topic: Review what students have learned so far in Mission 6.
Randomly group students into pairs for pair programming, or they can work individually.
Students log in to one computer. Two computers can be used if they want to have the activity guide open on one computer and CodeSpace on the other computer.
Students go to make.firialabs.com and start in Mission 6 at Objective 8. Students open their Heart2_functions program.
int(). To convert a value to float, use: float().Extension: Create a flowchart of the program.
✅ The assignment is complete and ready to turn in.
Use a formative assessment for the wrap-up.
Formative assessment:
- Daily reflection journal
- Mission 6 Kahoot Review (in class or individual)
- Exit ticket on incrementing and decrementing
- Exit ticket on data types
- Group review on incrementing, decrementing, and data types