AP CSP CodeX - Mission 5: Micro Musician

Mission 5 Lesson Plan

Mission 5: Micro Musician

Students play built-in MP3 files on the CodeX and make their code easier to read with blank lines and comments.

⏰ 45 min 🎯 Grades 9-12 💻 CodeSpace 🎮 CodeX 🐍 Python
View Lesson Outline
📋

Overview

Mission 5 is a short one. Students learn the code for playing pre-loaded MP3 files on the CodeX, then use blank lines and comments to make their code easier to read. Because the coding portion is shorter than Mission 4, there is time to review earlier concepts and introduce analog and digital data before students begin. Students finish by running their program on batteries, with no computer attached.

🎯 Mission Goal: Students will play a built-in MP3 on the CodeX, show an image, and make their code readable with blank lines and comments.

🎯

Learning Targets

  • I can make the CodeX play music through the speaker or headphones.
  • I can add blank lines and comments to my code to increase the readability.
💡

Key Concepts

  • Program readability is important and can be accomplished by using blank lines and adding comments to the code.
  • Batteries in the CodeX can make your code portable.
  • The audio function used in this mission is "blocking," which means no other code will execute while the audio plays. Non-blocking functions are introduced in Mission 13. You can also use the Non-Blocking Audio document.
✅

Assessment Opportunities

☑️

Success Criteria

  • Create a program that plays an audio file
  • Add readability to the code by adding blank lines and comments
  • Debug any errors in the code
🧰

Classroom Materials

  • ▸CodeX
  • ▸USB-C cable
  • ▸Computer
🌍

Real-World Applications

🎵Computer-controlled music sequences are very common in entertainment, such as musical gift cards, ringtones, drum machines, and keyboard synthesizers.
🚨Computer-controlled tones are also used for alarms and alert messages. Students can probably think of many more examples.
🔋The CodeX is an embedded computer, so it can be built into other projects to sense and control things in the physical world, running on batteries with no computer attached.
🚀

Extensions & Cross-Curricular

ExtensionCreate a string variable for the audio file and use it in your code.
ExtensionProgram several buttons to play music.
ExtensionBefore the music plays, turn on the color of the pixels, display an image, or fill the screen with a color.
ExtensionAdd your own MP3 audio files to the CodeX using the Adding Audio to CodeX slides.
ScienceStudents connect the Analog and Digital Data slides to how sound works. Speakers and headphones convert electrical signals into mechanical waves.
Lang ArtsStudents keep a daily journal, or use a reflection form, to process what they learned and write down questions they still have.
🔤

Vocabulary

▾
Readability - Making code easy to understand for humans.
Comments - Notes in code that are ignored by the computer but can explain what the code does.
Analog - Smooth and continuous signals that represent a quantity, like sound waves.
Digital - A numerical representation of an analog signal, represented in increments.
🐍

New Python Code

▾
audio.mp3("sounds/welcome")Play a built-in audio file
📐

Standards

▾

CSTA Standards - Grades 9-10

3A-AP-21

CSTA Standards - Grades 11-12

3B-AP-16

AP CSP Framework - Learning Objectives

CRD-2.G - Describe the purpose of a code segment or program by writing documentation.

AP CSP Framework - Computational Thinking Practices

5.A - Explain how computing systems work.
📝
Preparing for the Lesson
  • Prepare the assignment to give through your LMS.
  • If you have a word wall, or another form of vocabulary presentation, prepare the new terms.
  • If you have batteries for the CodeX, have them ready for Objective 6.

🧑‍🏫
Teacher Notes
  • Start the lesson by going over the Analog and Digital Data slides.
  • Something to watch for! Objective 4 has names of MP3 files loaded onto the CodeX. In order to play the files, the folder they are in must be included. Students always need to use the ("sounds/filename") path in their code.
  • Something to watch for! Students can use double quotes (" ") or single quotes (' '). Either one works.
  • Students are asked to add a multiline comment to the top of their code in Objective 5. The assignment calls this a docstring.
  • The Mission 5 Kahoot Review covers concepts and vocabulary from the earlier missions as well.
  • Students can add their own audio files to their CodeX. Use the instructions in the Adding Audio to CodeX slides.
  • The audio.mp3() function is blocking. For a quick look at non-blocking audio functions, refer to the Non-Blocking Audio document.
  • 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.

🗣️Warm-up

The coding part of this mission is much shorter than Mission 4. You should have time to do some coding review, and also introduce analog, digital, and music before starting the coding portion. Depending on the length of your warm-up and how quickly students complete the mission, they may have time for an extension.

Review concepts from Mission 4 by playing the Mission 4 Kahoot Review, especially if you did not have time to play it during the mission.

Analog and Digital Data: Use the Analog and Digital Data slides to go over these key concepts and how a computer processes data.

Discuss: Use a discussion strategy, like journaling, working at boards, selecting random students, or a form of think-pair-share. What is analog and digital sound? You can ask students what they already know about these terms and/or music. Use the slides to provide a mental model and definitions. The NBC News video Learn about analog and digital sound is also a really good resource. It is just under 5 minutes long.

💻Activity - Mission 5

Students can work individually or in pairs for pair programming.

Students go to make.firialabs.com and should be at the beginning of Mission 5.

Teaching tip - Objective 1: Students will need to click on the audio tool and answer questions in the assignment.
Teaching tip - Objective 4: Students experiment playing different sounds and songs on the CodeX, using the pre-loaded audio files. The examples in CodeSpace have the name of the audio file, but they do not include sounds/. To play a built-in file, students must include sounds/ in front of the name. Students can use double quotes or single quotes. Either one works.
Note: Students may want to play their own audio files. They can add MP3 files to the CodeX. However, students will need to use the same CodeX each time they run the program in order to access the files. Use the instructions in the Adding Audio to CodeX slides.
Note: Students may want to stop the play of a long song. At this time, that cannot be done, other than restarting the CodeX or clicking STOP for the program execution. Once a song starts, it will play through before anything else happens. To see how to use non-blocking audio functions, refer to the Non-Blocking Audio document.
Teaching tip - Objective 6: This objective has students put batteries in the CodeX and run their program "unplugged." If you do not have batteries, the students can still complete the mission, since the only requirement is to find the BATT switch on the simulator. However, if you have batteries, it is a good experience for the students to try it out here.
Teaching tip - Extension: This mission should take a regular class period with the warm-up and wrap-up. However, if some students finish early, or you have a shorter warm-up and wrap-up, they may have time for an extension. Students can come up with their own idea, or try one of these:
  • Create a string variable for the audio file and use it in your code
  • Program several buttons to play music
  • Before the music plays, add one or more of these: turn on the color of the pixels, display an image, or fill the screen with a color
Teaching tip - Extension: Another possibility for an extension is to let students add their own MP3 audio files to the CodeX. Instructions are in the Adding Audio to CodeX slides. Try it yourself first before having students do it. There is a lesson later on where students will add their own images to the CodeX, so you can wait until then and not miss out on anything.

✅ The assignment is complete and ready to turn in.

🧑‍🤝‍🧑Wrap-Up

Discuss: Use a discussion strategy, like journaling, working at boards, selecting random students, or a form of think-pair-share. This discussion question is also excellent as a warm-up.

What are some real-world applications of digital music? Some examples include:

  • Musical gift cards
  • Ringtones
  • Drum machines
  • Keyboard synthesizers

If this lesson is completed in one class period, the following can be used as a wrap-up. If you are on a block schedule and continuing to the next lesson, a wrap-up isn't necessary.

Formative assessment:

  • Daily reflection journal
  • Completion of the assignment
  • Music1 program
  • Mission 5 Kahoot Review (reviews topics from previous missions as well as Mission 5)
  • Exit ticket on vocabulary
  • Group review on vocabulary