22 lines
449 B
Python
Executable file
22 lines
449 B
Python
Executable file
# SPDX-FileCopyrightText: 2021 Brent Rubell for Adafruit Industries
|
|
#
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
"""
|
|
'button_press.py'.
|
|
|
|
=================================================
|
|
push the button and light up a led
|
|
"""
|
|
import digitalio
|
|
import board
|
|
|
|
led = digitalio.DigitalInOut(board.D13)
|
|
led.switch_to_output()
|
|
button = digitalio.DigitalInOut(board.D2)
|
|
button.switch_to_input()
|
|
|
|
|
|
while True:
|
|
btn_state = button.value
|
|
led.value = not btn_state
|