27 lines
434 B
Go
27 lines
434 B
Go
package main
|
|
|
|
import (
|
|
"machine"
|
|
"time"
|
|
)
|
|
|
|
func main() {
|
|
|
|
led := machine.LED
|
|
led.Configure(machine.PinConfig{Mode: machine.PinOutput})
|
|
|
|
// button A is on pin P1_06, active LOW (internal pull-up)
|
|
btnA := machine.P1_06
|
|
btnA.Configure(machine.PinConfig{Mode: machine.PinInputPullup})
|
|
|
|
for {
|
|
// button reads LOW when pressed
|
|
if !btnA.Get() {
|
|
led.High()
|
|
} else {
|
|
led.Low()
|
|
}
|
|
|
|
time.Sleep(time.Millisecond * 10)
|
|
}
|
|
}
|