17 lines
403 B
Python
17 lines
403 B
Python
from machine import PWM, Pin
|
|
from utime import sleep
|
|
|
|
# From https://github.com/udacity/cd13765-deci-emb-sys-l4-term2-project.git
|
|
|
|
class Buzzer:
|
|
def __init__(self, pin):
|
|
self.pin = pin
|
|
self.buzzer = PWM(Pin(pin, Pin.OUT))
|
|
self.buzzer.duty(0)
|
|
|
|
def beep_once(self):
|
|
self.buzzer.freq(1047)
|
|
self.buzzer.duty(50)
|
|
sleep(0.2)
|
|
self.buzzer.duty(0)
|