mirror of
https://github.com/Djeeberjr/fw-anwesenheit.git
synced 2025-07-01 08:44:18 +00:00
24 lines
452 B
Python
24 lines
452 B
Python
import RPi.GPIO as GPIO
|
|
import time
|
|
|
|
BUZZER_PIN = 26
|
|
|
|
def beep(frequency, duration):
|
|
pwm = GPIO.PWM(BUZZER_PIN, frequency)
|
|
pwm.start(50) # 50 % duty cycle
|
|
time.sleep(duration)
|
|
pwm.stop()
|
|
|
|
def main():
|
|
GPIO.setmode(GPIO.BCM)
|
|
GPIO.setup(BUZZER_PIN, GPIO.OUT)
|
|
|
|
try:
|
|
beep(523, 0.3) # C5
|
|
beep(659, 0.3) # E5
|
|
beep(784, 0.3) # G5
|
|
finally:
|
|
GPIO.cleanup()
|
|
|
|
if __name__ == "__main__":
|
|
main() |