Musical instrument

Concept:

For this week’s assignment, we were struggling to come up with an idea so we scouted the internet for inspiration. We came across this video https://www.youtube.com/watch?v=J8XNTHETgxU and thought it was a perfect and cool idea! The concept is essentially playing notes by moving your hands at a certain distance away from the ultrasonic sensor. The notes we used were C,D,E,F,G,A,B. The materials we needed were one breadboard, 9 wires, one ultrasonic sensor, one switch, one 10ohms resistor, and one piezo buzzer. We also placed down pieces of paper with the notes on it to help us navigate the keys.

This is an attempt at drawing the schematic:

This is what the breadboard looked like:

This is the final outcome where we played mary had a little lamb:

This is the code we are most proud of:
// plays note at a certain distance

if (distance < 0 || distance > 50 || buttonState == LOW) { //if not presed and not in front

noTone(9); //dont play music

}

else if (( buttonState == HIGH)) { //if pressed

int sound = map(distance, 0, 50, 0, 6); //map distance to the array of notes
tone(9, notes[sound]); //call a note depending on distance

}

Reflections and improvements:
Not sure if the schematic is correct. When we would reach A or B the sound would sometimes become fuzzy or cut out so it would be nice if we could fix that. It would be better if we designed our own keyboard.

Leave a Reply