I've been trying to access the Badger2040 buttons through Tinygo and not having any luck (I have succeeded in CircuitPython before).
When I try to change the led state based on Button A, the led is switched on and never switches off:
package main
import (
"machine"
"time"
)
func main() {
led := machine.LED
led.Configure(machine.PinConfig{Mode: machine.PinOutput})
button_a := machine.BUTTON_A
button_a.Configure(machine.PinConfig{Mode: machine.PinInputPullup})
for {
led.Set(button_a.Get())
time.Sleep(time.Second / 4)
}
}
If I change the led.Set to pass in !button_a.Get()
then the led is always off.
It appears that button_a.Get() is always returning true.
Does anyone have any ideas please?