This commit is contained in:
2025-09-23 21:59:25 +02:00
commit 11272106b7
3 changed files with 120 additions and 0 deletions

28
print.py Normal file
View File

@@ -0,0 +1,28 @@
import RPi.GPIO as GPIO
import time
# ----------------------------
# Setup
# ----------------------------
GPIO.setmode(GPIO.BCM) # Use BCM numbering
PIN = 26 # The pin you want to monitor (BCM26)
# Setup pin as input with pull-up
GPIO.setup(PIN, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
print(f"Monitoring GPIO{PIN}. Press Ctrl+C to exit.")
try:
while True:
if GPIO.input(PIN): # Pin is HIGH (1)
print(f"GPIO{PIN} is HIGH")
else: # Pin is LOW (0)
print(f"GPIO{PIN} is LOW")
time.sleep(0.1) # Check every 100 ms
except KeyboardInterrupt:
print("Exiting...")
finally:
GPIO.cleanup()