2014-03-28 03:54:42 +01:00
|
|
|
// +build ignore
|
|
|
|
|
|
|
|
// PWM example, works OOTB on a BBB.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2014-04-04 22:13:16 +02:00
|
|
|
"flag"
|
2014-03-28 03:54:42 +01:00
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/kidoman/embd"
|
2014-04-06 03:20:09 +02:00
|
|
|
"github.com/kidoman/embd/host/bbb"
|
|
|
|
|
|
|
|
_ "github.com/kidoman/embd/host/all"
|
2014-03-28 03:54:42 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2014-04-04 22:13:16 +02:00
|
|
|
flag.Parse()
|
|
|
|
|
2014-03-28 03:54:42 +01:00
|
|
|
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()
|
|
|
|
|
2014-04-06 03:20:09 +02:00
|
|
|
if err := pwm.SetDuty(bbb.PWMDefaultPeriod / 2); err != nil {
|
2014-03-28 03:54:42 +01:00
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
time.Sleep(1 * time.Second)
|
|
|
|
}
|