Create cpx-buttons.py
initial code
This commit is contained in:
parent
5ac2fff6ea
commit
17a45afdf7
1 changed files with 19 additions and 0 deletions
19
Make_It_Sense/cpx-buttons.py
Normal file
19
Make_It_Sense/cpx-buttons.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
from digitalio import DigitalInOut, Pull, Direction
|
||||
import board
|
||||
|
||||
button_a = DigitalInOut(board.BUTTON_A)
|
||||
button_a.direction = Direction.INPUT
|
||||
button_a.pull = Pull.DOWN
|
||||
|
||||
button_b = DigitalInOut(board.BUTTON_B)
|
||||
button_b.direction = Direction.INPUT
|
||||
button_b.pull = Pull.DOWN
|
||||
|
||||
switch = DigitalInOut(board.SLIDE_SWITCH)
|
||||
switch.direction = Direction.INPUT
|
||||
switch.pull = Pull.UP
|
||||
|
||||
# Get the values of the switches now
|
||||
last_buttona = button_a.value
|
||||
last_buttonb = button_b.value
|
||||
last_switch = switch.value
|
||||
Loading…
Reference in a new issue