34 lines
526 B
Go
34 lines
526 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"periph.io/x/conn/v3/gpio"
|
|
"periph.io/x/host/v3"
|
|
"periph.io/x/host/v3/orangepi/zero3"
|
|
"time"
|
|
)
|
|
|
|
func blinkLight(d time.Duration, pin gpio.PinIO) {
|
|
t := time.NewTicker(d)
|
|
for {
|
|
pin.Out(true)
|
|
<-t.C
|
|
pin.Out(false)
|
|
<-t.C
|
|
}
|
|
}
|
|
|
|
func main() {
|
|
s, err := host.Init()
|
|
if err != nil {
|
|
fmt.Printf("%s", err)
|
|
} else {
|
|
fmt.Printf("OK: %s\n\n", s.Loaded)
|
|
}
|
|
|
|
go blinkLight(500*time.Millisecond, zero3.PA1_3)
|
|
go blinkLight(250*time.Millisecond, zero3.PA1_12)
|
|
c := make(chan bool)
|
|
<-c
|
|
}
|