Created
July 21, 2019 19:32
-
-
Save jsiegmund/d25e378aff799f99bd5f71819d5a84ec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Libraries | |
import sys | |
import RPi.GPIO as GPIO # Importeer de GPIO bibliotheek. | |
from time import sleep ## Importeer de bibliotheek voor tijdfuncties | |
seconds = 5 | |
# Set the number of seconds to the provided argument | |
if len(sys.argv) > 2: | |
seconds = sys.argv[2] | |
print "seconds: " + str(seconds) | |
buzzer_pin = 22 # Geef het nummer van de pin op waar de speaker is aangesloten. | |
GPIO.setwarnings(False) | |
GPIO.setmode(GPIO.BCM) # GebruikBroadcom GPIO benaming van de pinnen. | |
GPIO.setup(buzzer_pin, GPIO.OUT) # Zet de speaker pin als uitgang. | |
print "Druk op CTRL+C om het programma te beeindigen." | |
i = 0 | |
try: | |
while i < seconds: | |
GPIO.output(buzzer_pin, True) # Zet speakerpin hoog. | |
sleep(.5) # Wacht even. | |
GPIO.output(buzzer_pin, False) # Zet speakerpin laag. | |
sleep(.5) # Wacht even. | |
i += 1 | |
except KeyboardInterrupt: | |
GPIO.output(buzzer_pin, False) # Zet speakerpin laag. | |
# GPIO netjes afsluiten | |
GPIO.cleanup() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment