You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

26 lines
546 B

from machine import Pin
from utime import sleep
led = Pin(15, Pin.OUT)
button = Pin(16, Pin.IN)
waittime = 0.2
state = False
running = True
# Setzt den Zustand der LED und wartet dann <wait> Sekunden.
def toogle_LED(state,wait):
if state:
led.on()
else:
led.off()
sleep(wait)
#Endlosschleife
while running:
state = not state # state hin- und herschalten
toogle_LED(state,waittime) # LED umschalten
pressed = button.value()
if pressed == 0:
led.off()
running = False
print('Button gedrückt, Ende')