Buzzer - passive buzzer¶
from ezblock import PWM, Buzzer, Music pwm = PWM("A0") # create pwm object buzzer = Buzzer(pwm) # create an Buzzer object with PWM object music = Music() # create music object buzzer.play(music.note("Low C"), music.beat(1)) # play low C for 1 beat buzzer.play(music.note("Middle C#")) # play middle C sharp buzzer.off() # turn buzzer off
Create an Buzzer object associated with the given pwm object. This allows you to then control buzzer.
on- Turn the buzzer on with a square wave
off- Turn the buzzer off
freq- Set the square wave frequency
play- Play freq, set off if a ms delay arguement is provided.
Buzzer.play(freq, ms) Buzzer.play(freq)