def createpulse(pw, dutycycle, init): if init == 1: buzzer.on(pin) time.sleep(dutycycle * pw) buzzer.off(pin) time.sleep((1 - dutycycle) * pw) else: buzzer.off(pin) time.sleep((1 - dutycycle) * pw) buzzer.on(pin) time.sleep(dutycycle * pw)
def create(pw, dutycycle, init): global off if init == 1: while True and off == False: buzzer.on(pin) time.sleep(dutycycle * pw) buzzer.off(pin) time.sleep((1 - dutycycle) * pw) else: while True and off == False: buzzer.off(pin) time.sleep((1 - dutycycle) * pw) buzzer.on(pin) time.sleep(dutycycle * pw) off = False
def sos(): for i in range(1): for i in range(1, 4): LED.red() buzzer.on() time.sleep(0.2) LED.off() buzzer.off() time.sleep(0.2) for i in range(1, 4): LED.red() buzzer.on() time.sleep(0.5) LED.off() buzzer.off() time.sleep(0.5) for i in range(1, 4): LED.red() buzzer.on() time.sleep(0.2) LED.off() buzzer.off() time.sleep(0.2)