code.py
 1  # SPDX-FileCopyrightText: 2018 John Park for Adafruit Industries
 2  #
 3  # SPDX-License-Identifier: MIT
 4  
 5  # Gemma M0 Password Vault
 6  # press cap touch pads to enter strong passwords over USB
 7  
 8  import time
 9  
10  import board
11  import touchio
12  import usb_hid
13  from adafruit_hid.keyboard import Keyboard
14  from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS
15  from digitalio import DigitalInOut, Direction
16  
17  led = DigitalInOut(board.D13)
18  led.direction = Direction.OUTPUT
19  
20  touch0 = touchio.TouchIn(board.A0)
21  touch1 = touchio.TouchIn(board.A1)
22  touch2 = touchio.TouchIn(board.A2)
23  
24  # the keyboard object
25  # sleep for a bit to avoid a race condition on some systems
26  time.sleep(1)
27  kbd = Keyboard(usb_hid.devices)
28  layout = KeyboardLayoutUS(kbd)
29  
30  while True:
31      if touch0.value:
32          led.value = True
33          print("A0 touched!")
34          layout.write("?F3ErPs5.C.m.0.d.S.")  # enter your own password here
35          time.sleep(1)
36  
37      if touch1.value:
38          led.value = True
39          print("A1 touched!")
40          layout.write("6@LKNs(WV[vq6N")  # enter your own password here
41          time.sleep(1)
42  
43      if touch2.value:
44          led.value = True
45          print("A2 touched!")
46          layout.write("3Ff0rT@9j2y&")  # enter your own password here
47          time.sleep(1)
48  
49      time.sleep(0.01)
50  
51      print("Waiting for cap touches")
52      # turn off the LED
53      led.value = False
54  
55      time.sleep(0.01)