1
0
Fork 0
mirror of https://github.com/kidoman/embd synced 2025-07-03 03:47:33 +02:00

gpio: pwm support for bbb

This commit is contained in:
Kunal Powar 2014-03-28 08:24:42 +05:30 committed by kunalpowar
parent 8d9f991fb0
commit 14b078a43e
7 changed files with 329 additions and 28 deletions

1
samples/.gitignore vendored
View file

@ -13,6 +13,7 @@ ledshort
lsm303
mcp4725
pca9685
pwm
servo
servoblaster
tmp006

30
samples/pwm.go Normal file
View file

@ -0,0 +1,30 @@
// +build ignore
// PWM example, works OOTB on a BBB.
package main
import (
"time"
"github.com/kidoman/embd"
)
func main() {
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(embd.BBBPWMDefaultPeriod / 2); err != nil {
panic(err)
}
time.Sleep(1 * time.Second)
}