We got the tone to play continuously but the little song wasn’t playing. We realized we pasted the code improperly and after fixing it, the tone played.
There are two circuits here, one provides power, and the other transmits the information from the arduino, to the sensor, and back to the arduino.
Blocking function: Function where the program doesn’t go to the next line until that line is executed.
If this is being executed as an asynchronous function, both the tone and the delay command are executing at the same time. To test whether it’s blocking or asynchronous, you can make the delay longer than the sound, if the delay and sound both sound like they’re happening for the same amount of time, it’s asynchronous because they’re overlapping.
If the delay is too long, you’ll miss readings because it is a blocking function so while you’re back to pressing, the program isn’t allowing the press to be read.