Example for direct GPIO control on Beaglebone
* Contains some annotated on potential gotchas * Penance for hybridgroup/gobot#98
This commit is contained in:
parent
c08c82b91a
commit
f0d1154270
|
@ -0,0 +1,25 @@
|
|||
// Use Gobot to control BeagleBone's digital pins directly
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/hybridgroup/gobot/platforms/beaglebone"
|
||||
"github.com/hybridgroup/gobot/platforms/gpio"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
beagleboneAdaptor := beaglebone.NewBeagleboneAdaptor("beaglebone")
|
||||
gpioPin := gpio.NewDirectPinDriver(beagleboneAdaptor, "myDevice", "P9_12")
|
||||
|
||||
// Initialize the internal representation of the pinout
|
||||
beagleboneAdaptor.Connect()
|
||||
|
||||
// Cast to byte because we are returning an int from a function
|
||||
// and not passing in an int literal.
|
||||
gpioPin.DigitalWrite(byte(myStateFunction()))
|
||||
}
|
||||
|
||||
// myStateFunction determines what the GPIO state should be
|
||||
func myStateFunction() int {
|
||||
return 1
|
||||
}
|
Loading…
Reference in New Issue