class Buzzer - passive buzzerΒΆ


from robot_hat import PWM, Buzzer, Music

pwm = PWM("A0")                 # create a pwm object
buzzer = Buzzer(pwm)            # create a Buzzer object with PWM object
music = Music()                 # create music object"Low C"), music.beat(1))   # play low C for 1 beat"Middle C#"))              # play middle C sharp                                      # turn buzzer off


class robot_hat.Buzzer(pwm): Create a Buzzer object associated with the given pwm object. This will allow you to control the buzzer.


  • on - Turn the buzzer on with a square wave.

  • off - Turn the buzzer off.
  • freq - Set the frequency of the square wave.

  • play - Make the buzzer sound at a specific frequency and stop at a ms delay time., ms)