Calling a Method several times with several Threads
问题 I want a LED to flash, while some work is beeing done on my Raspberry. I am using a Thread for the LED in my Python script. The initial code: import RPi.GPIO import time import threading pinLED = 10 pinButton = 12 GPIO.setmode(GPIO.BOARD) GPIO.setup(pinLED, GPIO.OUT) GPIO.setup(pinButton, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) GPIO.output(pinLED, 0) Method for the Thread: working = False def flash(): status = 0 while working: time.sleep(0.5) if status == 0: GPIO.output(pinLED, 1) status = 1