This repository has been archived on 2025-06-01. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
compLIB/compLib/Buzzer.py
Konstantin Lampalzer daef7c97e4
Rename folder
2021-01-16 02:10:40 +01:00

28 lines
459 B
Python

import atexit
import RPi.GPIO as GPIO
GPIO.setwarnings(False)
Buzzer_Pin = 17
GPIO.setmode(GPIO.BCM)
GPIO.setup(Buzzer_Pin, GPIO.OUT)
class Buzzer:
"""Used to interact with the buzzer
"""
@staticmethod
def set(on: bool):
"""Turn the buzzer on / off
:param on: True if on, False if off
"""
GPIO.output(Buzzer_Pin, on)
@staticmethod
def exit():
Buzzer.set(0)
atexit.register(Buzzer.exit)