logging
This commit is contained in:
@@ -3,21 +3,48 @@
|
||||
import RPi.GPIO as GPIO
|
||||
from time import sleep
|
||||
|
||||
__PIN__ = 18
|
||||
__PIN__ = 23 # GPIO Pin, den wir nutzen
|
||||
__WAIT__ = 0.5 # Warten für 0,5 Sekunden
|
||||
|
||||
GPIO.setwarnings(False)
|
||||
|
||||
# benutze Broadcom Pin Nummerierung
|
||||
GPIO.setmode(GPIO.BCM)
|
||||
|
||||
# Pin 23 als Output schalten.
|
||||
GPIO.setup(__PIN__,GPIO.OUT)
|
||||
|
||||
while True:
|
||||
#Zustand der LED setzen
|
||||
def setLED(state):
|
||||
|
||||
GPIO.output(__PIN__,GPIO.HIGH)
|
||||
print('LED ein')
|
||||
GPIO.output(__PIN__,state)
|
||||
|
||||
sleep(0.5)
|
||||
# Dauerschleife, die die LED im Wechsel ein- und ausschaltet.
|
||||
# Wird gestoppt mit CTRL-C
|
||||
def blinkloop():
|
||||
try:
|
||||
while True:
|
||||
|
||||
# Pin auf HIGH setzen schaltet die LED ein
|
||||
setLED(GPIO.HIGH)
|
||||
print('LED ein')
|
||||
|
||||
sleep(__WAIT__)
|
||||
|
||||
# Pin auf LOW setzen schaltet die LED aus
|
||||
setLED(GPIO.LOW)
|
||||
print('LED aus')
|
||||
sleep(__WAIT__)
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
finally:
|
||||
# Zum schluss immer die LED ausschalten.
|
||||
setLED(GPIO.LOW)
|
||||
|
||||
if __name__ =='__main__':
|
||||
blinkloop()
|
||||
GPIO.cleanup(__PIN__)
|
||||
|
||||
GPIO.output(__PIN__,GPIO.LOW)
|
||||
print('LED aus')
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user