In the while cycle of main function, when the button is pressed, subfunction alertor() will be called and the
alertor will issue a warning sound. The frequency curve of the alarm is based on the sine curve. We need to
calculate the sine value from 0 to 360 degree and multiply a certain value (here is 500) and plus the resonant
frequency of buzzer. We can set the PWM frequency through p.ChangeFrequency(toneVal).
def alertor():
p. start(50)
for x in range(0,361):
sinVal = math.sin(x * (math.pi / 180.0))
toneVal = 2000 + sinVal * 500
p. ChangeFrequency(toneVal)
time.sleep(0.001)