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
Thomas Kohler 865e724af0
Build(v2): revert move to v2 subfolder (#932)
* revert move to v2 subfolder
* fix CI and adjust CHANGELOG
2023-05-29 19:23:28 +02:00

31 lines
703 B
Go

//go:build example
// +build example
//
// Do not build by default.
package main
import (
"gobot.io/x/gobot/v2/drivers/gpio"
"gobot.io/x/gobot/v2/platforms/beaglebone"
)
func main() {
// Use Gobot to control BeagleBone's digital pins directly
beagleboneAdaptor := beaglebone.NewAdaptor()
gpioPin := gpio.NewDirectPinDriver(beagleboneAdaptor, "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
}