AP CSP CodeX - Mission 13: Sounds Fun
Mission 13: Sounds Fun
Students build a race day controller with a menu, sound effects and music on the CodeX, using a graphical user interface.
Overview
During this mission, students create a user-friendly graphical user interface (GUI) for the CodeX so it can act as a race day controller. They draw a four-item menu, move a selection rectangle with the buttons, and use the soundlib module to play music and sound effects. Along the way they work with local and global variables, for loops, blocking and non-blocking functions, and the not operator. This mission takes about two class periods, and works well split into two days.
🎯 Mission Goal: Students will create a user-friendly graphical user interface for CodeX so that it can act as a race day controller.
Learning Targets
- I can explain what a GUI is used for in a computer application.
- I can explain the difference between a local and global variable.
- I can use a for loop to iterate over a list.
- I can distinguish between a blocking and non-blocking function.
- I can use the not logical operator accurately in a program.
Key Concepts
- Variables defined inside of a function are local variables; variables defined outside of functions are global variables.
- The soundlib Python module has functions to create different types of tones, as well as playing recorded samples and MP3s.
- The for loop is made for looping across a range of numbers, or iterating over lists.
- Blocking functions block your code from continuing until they finish.
- Non-blocking functions allow code to continue to run without waiting for sound to finish.
- Use the not logical operator to flip the state of a global variable.
- A screen is made up of pixels, each with a location (x, y). The x values are columns going across, and the y values are rows going down.
- The upper left corner of the screen is (0, 0) and the lower right corner is (239, 239).
Assessment Opportunities
- Mission 13 Assignment
- Race_Control program
- Mission 13 Obj. 1-6 Kahoot! Review
- Mission 13 Obj. 7-11 Kahoot! Review
Success Criteria
- Display a GUI with four menu items
- Use a rectangle to show which menu item is selected
- Scroll the selection rectangle up and down to the different menu items
- Select a menu item using BTN A
- Play music in the background
- Play music for starting the race
- Play music for finishing the race
- Play music as a warning sound
Digital Resources
- ▸Mission 13 Assignment
- ▸Mission 13 Obj. 1-6 Kahoot! Review
- ▸Mission 13 Obj. 7-11 Kahoot! Review
- ▸Optional: Functions and Global Variables slides (from the Create PT Prep unit)
- ▸Code Solutions and Assignment Answers - Teacher Dashboard > Educator Resources button
Classroom Materials
- ▸CodeX
- ▸USB-C cable
- ▸Computer
Real-World Applications
- Operating systems, like Windows and macOS
- Mobile and web apps
- Web browsers, like Chrome and Safari
- Internet of Things, like smart home devices
- Medical equipment
Extensions & Cross-Curricular
🔤
Vocabulary
▾
🐍
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.
- The completed program uses a mix of global and local variables. It helps to have completed the "Functions and Global Variables" assignment from the Create PT Prep unit. Have the slides from that lesson ready if students need a review.
- Plan for two class periods. If you split the mission, stop after Objective 6 on day one and have the Mission 13 Obj. 1-6 Kahoot! Review ready.
- If you have a word wall, or another form of vocabulary presentation, prepare the new terms.
- Encourage the students to do as much code on their own as they can, and use CodeTrek to check their work, or as a hint when needed.
- The assignment adds an extra step to complete after Objective 11, and a challenge.
- You can divide the mission into two days. On the first day, stop after Objective 6 and use the Mission 13 Obj. 1-6 Kahoot! Review. The second day will complete Objectives 7-11 and the final steps. Use the Mission 13 Obj. 7-11 Kahoot! Review. If time permits, include the challenge as well.
- 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.
In this mission you will use a list. What do you remember about lists? Have a brief discussion. This mission will also use a global variable that is changed in a function. What do you remember about local and global variables? Have a brief discussion. Use the Functions and Global Variables slides if needed.
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 assignment open on one computer and CodeSpace on the other computer.
Students go to make.firialabs.com and should be at the beginning of Mission 13.
max() and min() functions for the first time. You may want to review what these functions do, and give the students some practice. Students will answer two more questions in their assignment.NOTE: CodeTrek introduces a new variable to keep track of the previous menu selection. CodeTrek doesn't specifically stop on this line of code (line 33) but there is a comment about it. You might want to point it out.
NOTE: The code will cause a new error with a global variable. It is discussed and fixed in the next objective. But students MUST throw the error to meet the goal of the objective.
NOTE: Students need to be careful where they erase the rectangle. It needs to be BEFORE they draw the new rectangle.
Continue either in pairs or individually. Students go to make.firialabs.com and should be on Objective 7 of Mission 13.
stop() to quit playing the tone at the given pitch.This objective also uses a "toggle" Boolean variable. If this is a difficult concept for your students, you will want to review and practice it. CodeTrek does not specifically stop on this line of code (#45) so you may need to specifically point it out.
✅ The assignment is complete and ready to turn in.
Discussion: You can now make a GUI on CodeX! This is a very useful skill that you can apply to many other programs. What are some programs you already created that could use a GUI?
Students complete the wrap-up questions on the assignment. You can have a short discussion on their answers.
Optional. Use a formative assessment for the wrap-up.
Formative assessment:
- Daily reflection journal
- Mission 13 Obj. 1-6 Kahoot! Review
- Mission 13 Obj. 7-11 Kahoot! Review (in class or individual)
- Exit ticket on lists
- Exit ticket on global and local variables
- Exit ticket on blocking and non-blocking functions