In this exercise, we will use the Open Roberta editor. Make sure that you can see this image in the top right-hand corner of your programming environment. You can find the editor on our website at the top of the navigation bar under Programming - Editors.
First steps: The mini Piano
Become a music pro on the mini.
Select the following block in the menu under Control and attach it to the Start block to play your code in an endless loop.
From the Control menu sub-item, take the If - make block and select the Pin pressed? block under Sensors to control the individual pins. Click on 0 in the selection.
You can display the note name by inserting the Show Text block from the Action menu. Change Text to Characters to display the individual note names. Now type in the name of your note.
To play a sound, insert the play whole note... block from the extended menu under Action and Sound. If you click on the note, a piano keyboard with further notes will open. You can click to select which note is played. You can also specify how long your note should be held.
To assign a note to additional pins, repeat steps 02-04 and make the following adjustments in sequence.
- change P0 to P1 etc.
- adjust the note name.
- select the appropriate note.
- change the note length.
Done - download your script now and try it out!
Important!
For the pins to work as input, a circuit must always be closed. Therefore, whenever you touch a pin to play a sound, you must touch the pin with the minus with your other hand.