Example for direct GPIO control on Beaglebone

* Contains some annotated on potential gotchas
* Penance for hybridgroup/gobot#98
This commit is contained in:
Trevor Rosen 2014-08-23 14:13:23 -05:00
parent c08c82b91a
commit f0d1154270
No known key found for this signature in database
GPG Key ID: 4D33193C06959BCB
1 changed files with 25 additions and 0 deletions

View File

@ -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
}