示例#1
0
文件: badge.py 项目: jantje/badge
class Buzzer:
    def __init__(self, pin=Pin(33)):
        """
        Create a new Buzzer instance

        @param pin: 	the machine.Pin on which the servo is connected
        """
        self.pwm = PWM(pin, freq=3000)

    def enable(self):
        """
        Enable the output of the buzzer
        """
        self.pwm.resume()

    def disable(self):
        """
        Disable the output of the buzzer
        """
        self.pwm.pause()

    def set(self, freq):
        """
        Set the frequency

        @param freq:     the frequency to set
        """
        self.pwm.duty(freq)
示例#2
0
class Buzzer:
    def __init__(self, pin=Pin(33)):
        """
        Create a new Buzzer instance

        @param pin: 	the machine.Pin on which the servo is connected
        """
        self.pwm = PWM(pin, freq=3000)

    def enable(self):
        """
        Enable the output of the buzzer
        """
        self.pwm.resume()

    def disable(self):
        """
        Disable the output of the buzzer
        """
        self.pwm.pause()

    def set(self, freq):
        """
        Set the frequency

        @param freq:     the frequency to set
        """
        self.pwm.duty(freq)