2017-03-13 23:01:39 +08:00
|
|
|
// +build example
|
|
|
|
//
|
|
|
|
// Do not build by default.
|
|
|
|
|
2014-08-24 03:13:23 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2016-12-08 20:24:03 +08:00
|
|
|
"gobot.io/x/gobot/drivers/gpio"
|
|
|
|
"gobot.io/x/gobot/platforms/beaglebone"
|
2014-08-24 03:13:23 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2014-10-29 05:52:59 +08:00
|
|
|
// Use Gobot to control BeagleBone's digital pins directly
|
2016-10-03 22:58:43 +08:00
|
|
|
beagleboneAdaptor := beaglebone.NewAdaptor()
|
|
|
|
gpioPin := gpio.NewDirectPinDriver(beagleboneAdaptor, "P9_12")
|
2014-08-24 03:13:23 +08:00
|
|
|
|
|
|
|
// 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
|
|
|
|
}
|