mirror of
https://github.com/kidoman/embd
synced 2024-11-13 04:58:55 +01:00
c35deeb17c
this ensures cleaner abstractions/code and will ensure that the produced binary is as small as possible. a convenience package is provided to easily load all hosts easily: "github.com/kidoman/embd/host/all"
37 lines
513 B
Go
37 lines
513 B
Go
// +build ignore
|
|
|
|
// PWM example, works OOTB on a BBB.
|
|
|
|
package main
|
|
|
|
import (
|
|
"flag"
|
|
"time"
|
|
|
|
"github.com/kidoman/embd"
|
|
"github.com/kidoman/embd/host/bbb"
|
|
|
|
_ "github.com/kidoman/embd/host/all"
|
|
)
|
|
|
|
func main() {
|
|
flag.Parse()
|
|
|
|
if err := embd.InitGPIO(); err != nil {
|
|
panic(err)
|
|
}
|
|
defer embd.CloseGPIO()
|
|
|
|
pwm, err := embd.NewPWMPin("P9_14")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
defer pwm.Close()
|
|
|
|
if err := pwm.SetDuty(bbb.PWMDefaultPeriod / 2); err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
time.Sleep(1 * time.Second)
|
|
}
|