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:
parent
8d9f991fb0
commit
14b078a43e
7 changed files with 329 additions and 28 deletions
1
samples/.gitignore
vendored
1
samples/.gitignore
vendored
|
@ -13,6 +13,7 @@ ledshort
|
|||
lsm303
|
||||
mcp4725
|
||||
pca9685
|
||||
pwm
|
||||
servo
|
||||
servoblaster
|
||||
tmp006
|
||||
|
|
30
samples/pwm.go
Normal file
30
samples/pwm.go
Normal 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)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue