mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-07-26 10:38:41 +00:00
0ea72e7f1e
Signed-off-by: deadprogram <ron@hybridgroup.com>
32 lines
515 B
Go
32 lines
515 B
Go
package main
|
|
|
|
import (
|
|
"machine"
|
|
"time"
|
|
|
|
"tinygo.org/x/drivers/makeybutton"
|
|
)
|
|
|
|
var (
|
|
led machine.Pin = machine.LED
|
|
button machine.Pin = machine.D10
|
|
key *makeybutton.Button
|
|
)
|
|
|
|
func main() {
|
|
led.Configure(machine.PinConfig{Mode: machine.PinOutput})
|
|
key = makeybutton.NewButton(button)
|
|
key.Configure()
|
|
|
|
for {
|
|
switch key.Get() {
|
|
case makeybutton.Pressed:
|
|
led.High()
|
|
case makeybutton.Released:
|
|
led.Low()
|
|
}
|
|
// the more frequent the more responsive
|
|
time.Sleep(50 * time.Millisecond)
|
|
}
|
|
}
|