Datasheet
key_pin = digitalio.DigitalInOut(pin)
key_pin.direction = digitalio.Direction.INPUT
key_pin.pull = digitalio.Pull.UP
key_pin_array.append(key_pin)
led = digitalio.DigitalInOut(board.D13)
led.direction = digitalio.Direction.OUTPUT
print("Waiting for key pin...")
while True:
# Check each pin
for key_pin in key_pin_array:
if not key_pin.value: # Is it grounded?
i = key_pin_array.index(key_pin)
print("Pin #%d is grounded." % i)
# Turn on the red LED
led.value = True
while not key_pin.value:
pass # Wait for it to be ungrounded!
# "Type" the Keycode or string
key = keys_pressed[i] # Get the corresponding Keycode or string
if isinstance(key, str): # If it's a string...
keyboard_layout.write(key) # ...Print the string
else: # If it's not a string...
keyboard.press(control_key, key) # "Press"...
keyboard.release_all() # ..."Release"!
# Turn off the red LED
led.value = False
time.sleep(0.01)
Connect pin A1
or
A2 to ground, using a wire or alligator clip, then disconnect it to send the key press "A" or the string
"Hello world!"
This wiring example shows A1 and A2 connected to
ground.
Remember, on Trinket, A1 and A2 are labeled 2 and 0!
On other boards, you will have A1 and A2 labeled as
expected.
Create the Objects and Variables
© Adafruit Industries https://learn.adafruit.com/adafruit-itsybitsy-nrf52840-express Page 158 of 179










