forked from hybridgroup/gobot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Example for direct GPIO control on Beaglebone
* Contains some annotated on potential gotchas * Penance for hybridgroup#98
- Loading branch information
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |