import time
import board
import digitalio
schakelaar_poort = board.GP10
schakelaar = digitalio.DigitalInOut(schakelaar_poort)
schakelaar.direction = digitalio.Direction.INPUT
schakelaar.pull = digitalio.Pull.DOWN
pulse_telling = 0
huidige_staat = False
while True:
while huidige_staat == False and schakelaar.value == True:
huidige_staat = True
time.sleep(0.5)
if huidige_staat == True and schakelaar.value == False:
pulse_telling += 1
print("Puls gedetecteerd. Telling:", pulse_telling)
huidige_staat = False