mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-04 02:57:46 +00:00
27 lines
355 B
Go
27 lines
355 B
Go
package main
|
|
|
|
import (
|
|
"machine"
|
|
"time"
|
|
)
|
|
|
|
const (
|
|
led = machine.LED
|
|
button = machine.BUTTON
|
|
)
|
|
|
|
func main() {
|
|
led.Configure(machine.PinConfig{Mode: machine.PinOutput})
|
|
button.Configure(machine.PinConfig{Mode: machine.PinInputPullup})
|
|
|
|
for {
|
|
if button.Get() {
|
|
led.Low()
|
|
} else {
|
|
led.High()
|
|
}
|
|
|
|
time.Sleep(time.Millisecond * 10)
|
|
}
|
|
}
|