BETTER PIANO
In this project, we improve on the Simple Piano we created in the previous project by monitoring the buttons and playing the notes for the duration of the button press.
Speaker & Audio Cable
Hardware setup from the MANY BUTTONS project.
Having issues? Check out the Troubleshooting Guide.

Using the same hardware setup from the 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:


Step #1: Build the circuit.

Your breadboard should still have the circuit we wired in the MANY BUTTONS project. As a reminder, here is what it should look like:

Step #2: Write the code.

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:


home | prev | next