package main import ( log "github.com/sirupsen/logrus" "periph.io/x/conn/v3/gpio" "periph.io/x/host/v3" "periph.io/x/host/v3/orangepi/zero3" "time" ) func init() { log.SetFormatter(&log.JSONFormatter{}) log.SetLevel(log.DebugLevel) } func blinkLight(d time.Duration, pin gpio.PinIO) { t := time.NewTicker(d) for { log.WithField("pin", pin.String()).Debug("Turning ON") pin.Out(true) <-t.C log.WithField("pin", pin.String()).Debug("Turning OFF") pin.Out(false) <-t.C } } func getInput(pin gpio.PinIO) { for { val := pin.WaitForEdge(500 * time.Millisecond) log.WithField("pin", pin.String()).Infof("Received" val) } } func main() { s, err := host.Init() log.Infof("hello wprld") if err != nil { log.Fatal("periph not loaded", err) } else { log.Infof("periph loaded with", s.Loaded) } //go blinkLight(500*time.Millisecond, zero3.PA1_3) //go blinkLight(250*time.Millisecond, zero3.PA1_12) go getInput(zero3.PA1_5) c := make(chan bool) <-c }