My buzzer will not stop buzzing

I am trying to make a motion sensor and for it, I have to have it so that when there is not any motion it buzzes but when there is it will buzz but I need it to sense a blink of an eye and it will not stop buzzing with my code plz help
the link to my code is

in case there is no motion you send playTone(0, 0); where the second zero is the freq
but in the function playTone() we see this line

int period = (1.0 / freq) * 1000000;

so you are dividing by zero!
I don't know if this is why your buzzer keep buzzing, so try something like playTone(0, x); where x>0 to avoid dividing by zero

I have the feeling you failed to read this. Please do it now, and follow the instructions on how to post a good question.