Idea

We created a digital piano/keyboard using buttons and a buzzer. The buzzer outputs a certain frequency based on what button is pressed, mimicking the functionality of a keyboard.

Process

We wanted to make the keyboard something users could easily interact, hence the buttons. Our original plan was to include around 15-20 keys for the user to play. That means we would have more inputs than the Arduino had so we planned to use a shift register. However, that was not possible in TinkerCAD so we decided to limit the number of notes to one scale C-B (white and black keys included). The theremin lab was quite helpful because it gave us insight on how to use the buzzer and how to code for specific pitches.

Components

Hardware

We used 11 push buttons (one for each key) and one buzzer, with the keys as input as the buzzer as output. We faced a challenge in that the number of pins in Arduino is less than the number of keys we originally wanted to create. We researched and explored possible solutions to effectively increase the number of inputs with a shift register, which included shifting-in with a CD4021BE; however, unfortunately, there is not a CD4021BE in TinkerCad. Another option was building a shift register from scratch, but my partner and I decided that we would save that challenge for another time and reduce the number of keys so that we could focus on making the keys work and play the correct notes. We both came in having little experience with electrical engineering, so through the hardware process we learned a lot!

Software

Our code begins by instantiating variables for the pins corresponding to each note and the frequencies for each note. In setup() we set all the buttons (keys) to inputs and the buzzer to output. Our loop() method is just a series of if statements which tell the buzzer what frequency to output based on which button is pressed with a delay at the end to hold the note.

Physical Build

If we were physically building this project we would've added multiple features. First, we would have been able to add more keys on our piano because Tinker Cad does not have a shift register. In addition, we could have 3D printed some keys so that the user would not have to press down on buttons.

Built With

Share this project:

Updates