# WiFiBoyMini PWM Sound Control
#

import machine, time

# Set PWM Pin#25 為 snd
#
machine.Pin(17,3).value(1) # Switch on Buzzer

snd = machine.PWM(machine.Pin(25, 3))

#
# PWM is a square wave generator
# Pin#25 is WiFiBoy32 buzzer IO

# Set buzzer frequency to 440Hz
#
# snd.freq(freq)
#
# freq = 10 ~1000 (Hz)
# Piano middle key (A4) is 440Hz
# Frequecy is doubled for increased octave
# So A3 is 220Hz and A5 is 880Hz
#

snd.freq(440)

# Set sound volume to 90%
#
# snd.duty(90)
# 
# snd.duty(0) turns off sound


snd.duty(90)

time.sleep(0.1)

snd.duty(0)

# close pwm sound
#
# snd.deinit()
#
