''' _____ ___ _ _ ____ _ _ |_ _/ _ \| | | |/ ___| | | | | || | | | | | | | | |_| | | || |_| | |_| | |___| _ | |_| \___/ \___/ \____|_| |_| script to test the TTP223 sensor /usr/bin/python3 /var/www/moduleair_pro_4g/touch/test.py ''' import RPi.GPIO as GPIO import time # Setup GPIO TOUCH_PIN = 6 # GPIO06 (BCM numbering) GPIO.setmode(GPIO.BCM) GPIO.setup(TOUCH_PIN, GPIO.IN) print("Touch sensor ready. Waiting for touch...") last_state = False # Track previous state (False = not touched) try: while True: current_state = GPIO.input(TOUCH_PIN) == GPIO.HIGH # If touch state has changed if current_state != last_state: if current_state: print("👋 Sensor touched!") else: print("🖐️ Sensor released!") last_state = current_state # Update last state time.sleep(0.1) # Polling interval except KeyboardInterrupt: print("\nExiting...") finally: GPIO.cleanup()