BuzzBoard By Majid and Hassan
Concept
For our project, we aimed to create a unique musical instrument using distance tracking sensors and buttons. After brainstorming various ideas, we were inspired to design a piano-like instrument that could be played by two hands, one is distance tracked and the other is pressing the buttons. There are 7 notes and 3 different octaves that can be played. The notes are determined by the distance and the octave is based on which button is pressed.
implementation
We decided to use ultrasonic sensor for detecting the hand distance and buttons for controlling different notes of the piano. The Arduino was also connected to a piezo sensor for producing the piano sounds. Once the circuit assembly was complete, we tested the circuit to ensure the sensors and buttons were working and registered properly. Then we programmed the buttons to play different octaves of the notes.
Deciding which note to be played is at the core of our code. We did so through making a list of if conditions. First we checked what was the last button pressed, to decide the octave we are playing the notes in. After that, based on the distance from the ultrasonic sensor, in increments of 3cm, we chose a note to be played. For example, here is how the notes are played if the last button pressed was 2:
if(lastButton == 2){ if (distance < 3) { tone(8,NOTE_A4,noteDuration); } else if (distance >= 3 && distance < 6) { tone(8,NOTE_B4,noteDuration); } else if (distance >= 6 && distance < 9) { tone(8,NOTE_C4,noteDuration); } else if (distance >= 9 && distance < 12) { tone(8,NOTE_D4,noteDuration); } else if (distance >= 12 && distance < 15) { tone(8,NOTE_E4,noteDuration); } else if (distance >= 15 && distance < 18) { tone(8,NOTE_F4,noteDuration); } else if (distance >= 18 && distance < 21) { tone(8,NOTE_G4,noteDuration); } }
Challenges
One of the main challenges we encountered during the project was calibrating the distance sensors to play different notes. We had to experiment with different threshold values and distances for the different notes and octaves.