To begin, I looked at the Arduino's audio library, snagged ToneMelody, and then began editing. I had used the HC Sr04 sensors in the past so I referred to my old working code when it came to connecting it to a buzzer.
After compiling my code, I uploaded to my UNO and the buzzer returned the original melody, just very slowly. I was not sure if this was because of the distance sensor or if there was a bug i n my code. After some trial and error, I concluded that it was the latter. In addition to these issues, I discovered that sometimes my code was returning distance values and sometimes it wasn't, leading me to believe that there were some connection issues. I switc
I ended up trying to debug for several hours, to eventually decide to relent and try again.
Take two:
I literally made two new sketches and made sure each component was working. I discovered that the proximity sensor was not returning any values
incosistently returning values! Thus led me to conclude that there were some connectivity issues
Goober successfully plays tune, now I just need to synchronize it with my distance sensor. In addition, I was able to get the distance sensor working as well! When it returns -1, the subject is out of bounds and will play the original pattern of tunes. Depending on how close the subject is to the sensor, the pattern will shift and speed up.
Unfortunately once I added the housing, it interfered with the sensor returning distance values. A potential future modification that could be made is if there were different thresholds that produced different songs.