snake_computer/05_taster.py

18 lines
517 B
Python
Raw Permalink Normal View History

2025-05-25 10:52:31 +02:00
from machine import Pin
import time
taster_hoch = Pin(1, Pin.IN, Pin.PULL_UP)
taster_runter = Pin(2, Pin.IN, Pin.PULL_UP)
taster_rechts = Pin(3, Pin.IN, Pin.PULL_UP)
taster_links = Pin(4, Pin.IN, Pin.PULL_UP)
def schleife():
if not taster_runter.value(): print('Runter gedrueckt!')
if not taster_rechts.value(): print('Rechts gedrueckt!')
if not taster_links.value(): print('Links gedrueckt!')
if not taster_hoch.value(): print('Hoch gedrueckt!')
while True:
schleife()
time.sleep(0.2)