Skip to content

Commit

Permalink
Example for direct GPIO control on Beaglebone
Browse files Browse the repository at this point in the history
* Contains some annotated on potential gotchas
* Penance for hybridgroup#98
  • Loading branch information
trevrosen committed Aug 23, 2014
1 parent c08c82b commit f0d1154
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions examples/beaglebone_basic_direct_pin.go
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
}

0 comments on commit f0d1154

Please sign in to comment.