Now that we have the lower pitches worked out with button A, let's make the upper pitches with button B.

We need to add an else if statement to our outer if statement to check for button B presses.

  • Click the plus sign that the bottom of the outer if statement twice to make the "else if, then" statement appear.
  • Now copy and paste just the "button A is pressed" statement from above and drag it into the else if condition.
  • Click the drop down and change it to button B.

Most of the code for button B is going to be the same as the code we wrote for button A. The pitches will just be one octave higher.

  • Copy and paste the entire block of code of the inner if statement we made earlier.
  • Now drag it inside the button B if statement.
  • Now let's change the pitches to be one octave higher. As mentioned earlier you can click on each note and change it by clicking your desired note on the piano.

This guide was first published on Apr 11, 2018. It was last updated on Mar 08, 2024.

This page (Adding Button B) was last updated on Mar 08, 2024.

Text editor powered by tinymce.