Link to lab: https://itp.nyu.edu/physicalcomputing/labs/tone-output-using-an-arduino/
I found the constant speaker output annoying, so for the frequency modulation, I added a threshold so it only started playing when the force sensor is squeezed
Controlling the frequency of speaker output with an force-sensitive resistor
Controlling the frequency of speaker output with an force-sensitive resistor
I played around a bit with the code for play a melody; to start out with, I just had it play a melody in a loop when the sensor is pressed:
Playing “In Dreams” from Lord of the Rings on loop
Playing “In Dreams” from Lord of the Rings on loop
Then I thought it would be fun to be able to change the starting pitch of the song, so I added code to read the sensor changes, record a peak value, and change the starting pitch of the song accordingly (squeezing harder = higher notes). After some playing around, I also added a “preview” of the starting pitch before the songs starts, to make the input easier to navigate. It took a decent amount of tweaking/iterating on the interaction, both with the code/logic and with the parameters, but I was more or less satisfied with the result in the end.
Changing the starting note of the music using the force sensitive resistor
Changing the starting note of the music using the force sensitive resistor
When playing a single A on the the speaker, when it first starts, it’s on a lower note (about a half step below A), then switches to A. This only seems to happen when the speaker first turns on — why is that?