1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-05-08 19:29:16 +08:00

Merge pull request #100 from trevrosen/dev

Example of connecting adaptor manually for minimal code to accomplish GPIO control
This commit is contained in:
Javier Cervantes 2014-08-25 09:54:18 -05:00
commit 1c20ec7eaf

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
}