SIMPLE PIANO
In this project, we integrate the multiple buttons we implemented several projects ago along with the note/sound generation from the sound library and the speaker.
Speaker & Audio Cable
Hardware setup from the MANY BUTTONS project.
Having issues? Check out the Troubleshooting Guide.

Using the hardware setup from Many Buttons, we can turn our RaspberrySTEM into a very basic sound machine. We will start with four buttons each wired to a GPIO as input, and write some code that will generate corresponding note when each button is pressed. We'll keep it simple in this project, and just play each note for one second.

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 code for this project is straightforward:

Here is what the code should look like:


home | prev | next