import BrainPad
def setup():
global buttonA
global buttonB
global display
global led
display=BrainPad.Display
display.Clear()
display.Show()
display.Print("Hello GHI !")
display.Print("")
display.Print("Push a Button")
led=BrainPad.Digital("led")
buttonA=BrainPad.Button("A",0)
buttonB=BrainPad.Button("B",0)
def loop():
global led
global buttonA
global buttonB
global display
if(BrainPad.In(buttonA)):
display.Print("A Button pressed")
BrainPad.Out(led,1)
if(BrainPad.In(buttonB)):
display.Print("B Button pressed")
BrainPad.Out(led,0)
BrainPad.Wait(0.02)
setup()
while True:
loop()
With machine package, microPython want a pin number.
Example :
On ESP32 Feather Huzzah : Led = Pin(13, Pin.OUT)
On Raspberry Pi Pico : Led = Pin(25, Pin.OUT)