1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-04-27 13:48:56 +08:00
hybridgroup.gobot/examples/beaglebone_basic_direct_pin.go
Trevor Rosen f0d1154270
Example for direct GPIO control on Beaglebone
* Contains some annotated on potential gotchas
* Penance for hybridgroup/gobot#98
2014-08-23 14:13:23 -05:00

26 lines
697 B
Go

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