Skip to content

gpiobtns

John "Warthog9" Hawley edited this page Mar 13, 2019 · 4 revisions

Example code to Set Up the Buttons

from machine import Pin

MicroPython

pin_btn_up    = 33
pin_btn_left  =  2
pin_btn_right = 34
pin_btn_down  = 27
pin_btn_mid   = 32

btn_array = [ btn_up, btn_left, btn_right, btn_down, btn_mid ]

btn_up    = Pin(pin_btn_up,    Pin.IN, Pin.PULL_UP)
btn_left  = Pin(pin_btn_left,  Pin.IN, Pin.PULL_UP)
btn_right = Pin(pin_btn_right, Pin.IN, Pin.PULL_UP)
btn_down  = Pin(pin_btn_down,  Pin.IN, Pin.PULL_UP)
btn_mid   = Pin(pin_btn_mid,   Pin.IN, Pin.PULL_UP)
Clone this wiki locally