< Unit 6 - Physical Computing ('22-'23)

Lesson 13: Making Music

45 minutes

Overview

In this lesson students will use the buzzer to its full extent by producing sounds, notes, and songs with the buzzer. Students start with a short review of the buzzer's frequency and duration parameters, then move on to the concept of notes. Notes allow students to constrain themselves to frequencies that are used in Western music and provide a layer of abstraction that helps them to understand which frequencies might sound good together. Once students are able to play notes on the buzzer, they use arrays to hold and play sequences of notes, forming simple songs.

Question of the Day: How can I use the buzzer to play musical notes or songs?

Assessment Opportunities

  1. Use the buzzer to produce individual notes or sequences of notes

    Code Studio: see rubric on the assessment level

CSTA K-12 Computer Science Standards (2017)
    • 2-AP-11 - Create clearly named variables that represent different data types and perform operations on their values.
    • 2-AP-13 - Decompose problems and subproblems into parts to facilitate the design, implementation, and review of programs.
    • 2-AP-19 - Document programs in order to make them easier to follow, test, and debug.
    • 2-CS-02 - Design projects that combine hardware and software components to collect and exchange data.
    • 2-CS-03 - Systematically identify and fix problems with computing devices and their components.

Agenda

Objectives

Students will be able to:
  • Use the buzzer to produce individual notes or sequences of notes

Preparation

  • Prepare a board and USB cable for each pair of students
  • Check the "Teacher's Lounge" forum for verified teachers to find additional strategies or resources shared by fellow teachers

Links

Heads Up! Please make a copy of any documents you plan to share with students.

For the teachers
For the students

Teaching Guide

Warm-Up (5 minutes)

Prompt: We've been using the buzzer to make sounds, but those buzzes didn't always sound too great. What do you think you need to make real music on the buzzer?

Discussion Goal: Students may come up with many different ideas, but there are two aspects of this problem that should be highlighted before students move on to the activity. First, specifying frequencies is not the best way to indicate musical notes, since music only uses certain tones and most other frequencies are considered “out of tune”. Second, students will need a way to string sounds, or notes, together to make a song rather then using individual buzzer.frequency() blocks.

Activity (35 minutes)

Making Music

Transition: Send students to Code Studio.

Teaching Tip

Guide to Programming Levels: Additional guidance for programming levels is provided in the CSD Guide to Programming Levels. This document includes strategies and best-practices for facilitating programming levels with students.

Discussion Goal

Students will have a tough time predicting their results here, but that's okay - it's more important that they realize that there should be matching sounds between the left buttons and the right buttons. When students run the code, they can press the buttons multiple times to try and find the matching pairs. They should discover the following pairs create the same sounds:

  • 261 <> C4
  • 329 <> E4
  • 493 <> B4
  • 392 <> G4

As students will discover soon, these frequencies correspond to musical notes like they might see on a piano. For now, they should leave this level understanding that certain frequencies correspond to certain "notes".

Discussion Goal

This level formally introduces students to arrays, which are like lists. Students have already been using arrays without realizing it - the colorLeds are an array of lights on the Circuit Playground. The array in this level works similar to the colorLeds. Help students notice the following:

  • Both arrays use square brackets [] with numbers inside to represent the position in the array
  • Both arrays seem to start with 0
  • The notes array is defined at the top of the code with a var block, but colorLEDs aren't defined anyway

Students will learn more about arrays in the video in the next lesson

Teaching Tip

Reviewing the Video: After watching the video, consider printing or displaying the corresponding Lesson Resource included as a PDF in the student resources of the lesson plan. This can be a helpful visual cue for students as they continue working through levels that require them to apply what they learned from the video, or can be used in a class discussion to summarize and clarify the content of the video. You can also remind students that these resources are available in the Help and Tips tab on individual levels.

Assessment Opportunity

Formative Assessment: This level can be used as a formative assessment. A rubric is provided in the level, and written feedback can be given to students. Click here to learn more about giving feedback to students.

Wrap-Up (5 minutes)

Journal

Prompt: How are the arrays we use for songs similar to the array we use for colorLEDs? How are the arrays different?

Share After giving students time to reflect in their own journals, have them share with a partner or in small groups.

Discussion Goal: Students should note that both situations are representing a list of items, so arrays make the most sense. Students may notice any of the following differences:

  • We can access each LED individually if we want to with an array, but with songs it’s better to access the entire list together to play them in sequence
  • There are always 10 LEDs, but the number of notes in a song can grow or shrink
  • When playing a song with tempo, we can have arrays within arrays. This doesn’t happen with the LEDs
Creative Commons License (CC BY-NC-SA 4.0).

This work is available under a Creative Commons License (CC BY-NC-SA 4.0).

If you are interested in licensing Code.org materials for commercial purposes contact us.