11. Pentatonic Buzz

As a group go through the tutorial steps on Circuit Playground Express (CPX) Music Lesson 11. Remember you need to run your program within the Code.org Maker app for this to work.

You will be controlling the buzzer on your CPX to play particular notes for particular lengths of time. Below is a description of the various components from Lesson 11 that will be helpful to you, followed by the description of the tasks for you to complete today.

Resources from Lesson 11

  1. Playing notes using particular frequencies corresponding to the notes on a piano keyboard:
Piano keyboard single octave
    1. The frequencies for each piano key (except the far-right black one) are shown in parenthesis:
    2. C4# (277) D4# (311) F4# (369) G4# (415) A4# (466)
    3. C4 (261) D4 (293) E 4(329) F4 (349) G4 (392) A4 (440) B4 (493) C5 (523)
    4. The second number given is the length of time the sound should be played in milliseconds, eg. buzzer.frequency( 440, 100); plays the frequency A4 (440) for 100 milliseconds.
  1. Notes can be triggered by CPX button presses.
  2. Playing high vs low notes by changing the frequency value. This could be mapped to particular CPX buttons or other sensors.
  3. Different sounds could be played when a CPX button is pressed down as opposed to when it is released back up.
  4. Sounds can be played by frequency or by note name. Thus the following two give you the same thing:
    1. buzzer.frequency( 440, 100);
    2. buzzer.note( "A4", 100);
  5. The notes in a sequence or song can be collected together in an array, so it is easier to manipulate. For example an array of three notes might be:
    1. // 0-based indexing is used. The left-most element is at index position 1, and the right-most is at index position 4
    2. // index: 0 1 2 3 4
    3. var notes = ["C4","D4","E4","G4","A4"];
  6. You can use a random number generator to play random notes from an array.
  7. Provide your own note to be played at random, triggered by a button press.
  8. buzzer.playNotes(...) can be used to play a set of notes in sequence.
  9. Create your own song to be played using buzzer.playNotes(...)
  10. The null value can be used to leave space between notes

Today's Tasks:

Use the tutorial steps given above to create a CPX program that does the following:

    1. When button A is pressed play a set of random notes from the pentatonic scale ("C4","D4","E4","G4","A4"). Notes in a pentatonic scale were used in our previous Focus Chimes assignment.
    2. When button B is pressed use buzzer.playNotes(...) to implement either the first part of taps, charge, or some other commonly recognizable tune

Rubric:

The grading criteria for this lab are:

  • 1 point: All group member names are given at the top of your code. Plays random notes from a pentatonic scale when button A is pressed.
    • 1 point: Uses buzzer.playNotes(...) to play a commonly recognizable tune when button B is pressed.
  • 1 point extra credit: Make particular colored LEDs correspond to particular notes, so that the lights are synchronized with the sounds.

Submitting your Work

Submit your document as a file attachment using the google form, calling the essay topic Music 11 (for the 11 am lab) or Music 12 (for the 12 noon lab)