1
0
mirror of https://github.com/kidoman/embd synced 2024-12-22 12:50:19 +01:00
embd/samples/pwm.go
Kunal Powar 779096e668 samples: enable flag parsing
this will allow people to use glog options (like -v=3) to increase
verbosity of the log output
2014-04-05 01:43:16 +05:30

34 lines
442 B
Go

// +build ignore
// PWM example, works OOTB on a BBB.
package main
import (
"flag"
"time"
"github.com/kidoman/embd"
)
func main() {
flag.Parse()
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)
}