1
0
mirror of https://github.com/kidoman/embd synced 2024-12-22 12:50:19 +01:00
embd/samples/pwm.go

37 lines
513 B
Go
Raw Normal View History

2014-03-28 08:24:42 +05:30
// +build ignore
// PWM example, works OOTB on a BBB.
package main
import (
"flag"
2014-03-28 08:24:42 +05:30
"time"
"github.com/kidoman/embd"
"github.com/kidoman/embd/host/bbb"
_ "github.com/kidoman/embd/host/all"
2014-03-28 08:24:42 +05:30
)
func main() {
flag.Parse()
2014-03-28 08:24:42 +05:30
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 {
2014-03-28 08:24:42 +05:30
panic(err)
}
time.Sleep(1 * time.Second)
}