mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-03 06:27:47 +00:00
cafe8df620
Signed-off-by: deadprogram <ron@hybridgroup.com>
31 lines
525 B
Go
31 lines
525 B
Go
package main
|
|
|
|
import (
|
|
"machine"
|
|
"time"
|
|
|
|
"tinygo.org/x/drivers/makeybutton"
|
|
)
|
|
|
|
var (
|
|
led machine.Pin = machine.LED
|
|
button machine.Pin = machine.BUTTON
|
|
key *makeybutton.Button
|
|
)
|
|
|
|
func main() {
|
|
led.Configure(machine.PinConfig{Mode: machine.PinOutput})
|
|
button.Configure(machine.PinConfig{Mode: machine.PinInputPullup})
|
|
key = makeybutton.NewButton(button)
|
|
|
|
for {
|
|
switch key.Get() {
|
|
case makeybutton.Pressed:
|
|
led.High()
|
|
case makeybutton.Released:
|
|
led.Low()
|
|
}
|
|
time.Sleep(30 * time.Millisecond)
|
|
}
|
|
}
|