pxt-calliope/docs/lessons/happy-birthday/challenges.md
Sam El-Husseini e3975e65e5 pxt-microbit Accessibility PR (#529)
* Accessibility changes
2017-09-07 13:42:08 -07:00

5.4 KiB

happy birthday blocks challenges

Coding challenges for finishing the song, happy birthday.

Before we get started

Complete the happy birthday activity and your code will look like this:

music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.D), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.F), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.E), music.beat(BeatFraction.Quarter));
basic.pause(100);
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.D), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.G), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.F), music.beat(BeatFraction.Quarter));
basic.pause(100);


~

Challenge 1

Let's code the third part of Happy Birthday!

To do this, you need to add blocks after the last line of the play blocks. We want to continue to adding musical chords with the play block. Then insert the appropriate chord blocks G, E, C, B, A to complete the third part of the song. Modify your code so that your code looks like this.

music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.D), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.F), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.E), music.beat(BeatFraction.Quarter));
basic.pause(100);
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.D), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.G), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.F), music.beat(BeatFraction.Quarter));
basic.pause(100);
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.A), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.F), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.E), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.D), music.beat(BeatFraction.Quarter));
basic.pause(100);
  • click *run * to see if the code works as expected.

Challenge 2

Finally, we continue to adding the appropriate play block and fit the following chords blocks F, E, C, D to complete the third part of the song. Modify your code so that your code looks like this.

music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.D), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.F), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.E), music.beat(BeatFraction.Quarter));
basic.pause(100);
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.D), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.G), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.F), music.beat(BeatFraction.Quarter));
basic.pause(100);
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.A), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.F), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.E), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.D), music.beat(BeatFraction.Quarter));
basic.pause(100);
music.playTone(music.noteFrequency(Note.A), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.A), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.B), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.F), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.G), music.beat(BeatFraction.Quarter));
music.playTone(music.noteFrequency(Note.F), music.beat(BeatFraction.Quarter));
  • click *run * to see if the code works as expected.

Challenge 3

You now have a the ability to create music on the @boardname@. Try to code another favourite song.