Using the same hardware setup from the BUILD A SIMPLE PIANO project, we can turn our RaspberrySTEM into a mini-keyboard. We will modify the code so that each time you press one of the buttons on the RaspberrySTEM, the corresponding note plays for as long as the button is held:
Your breadboard should still have the circuit we wired in the READING MULTIPLE BUTTONS project. As a reminder, here is what it should look like:
The main change in the code for this project is -- after detecting a button press -- to monitor the button state to determine if continues to be pressed, and if so, continue to play the note.
Here is what the code should look like: