code.py
1 # SPDX-FileCopyrightText: 2021 Brent Rubell for Adafruit Industries 2 # 3 # SPDX-License-Identifier: MIT 4 5 """ 6 'touch.py' 7 ================================================= 8 capactive touch with the Adafruit Metro 9 requires: 10 - touchio 11 """ 12 import time 13 import board 14 import digitalio 15 import touchio 16 17 led = digitalio.DigitalInOut(board.D13) 18 led.switch_to_output() 19 touch = touchio.TouchIn(board.A1) 20 21 while True: 22 if touch.value: 23 led.value = True 24 else: 25 led.value = False 26 time.sleep(1)