mirror of
https://github.com/kidoman/embd
synced 2024-11-12 12:38:55 +01:00
31 lines
419 B
Go
31 lines
419 B
Go
|
// +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)
|
||
|
}
|