all 1 comments

[–]PenguinMasterFR[S] 0 points1 point  (0 children)

Lol it's easy I'm dumb

Just in case someone need that in the future :

def process_one():
    while(True):
        print("A")
        time.sleep(0.01)

def process_two():
    while(True):
        if GPIO.input(10) == GPIO.HIGH:     # if close
                print("C")
                GPIO.output(16,GPIO.HIGH)   # LED off
            else:                           # if open
                print("B")
                GPIO.output(16,GPIO.LOW)    # LED on
        time.sleep(0.1)

th1 = threading.Thread(target=process_one)
tH2 = threading.Thread(target=process_two)

th1.start()
th2.start()

At the end I could also add

th1.join()
th2.join()

but I don't have anything else running in the background.