33 lines
576 B
Go
33 lines
576 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/hybridgroup/gobot"
|
|
"github.com/hybridgroup/gobot/platforms/gpio"
|
|
"github.com/hybridgroup/gobot/platforms/intel-iot/edison"
|
|
)
|
|
|
|
func main() {
|
|
gbot := gobot.NewGobot()
|
|
|
|
board := edison.NewEdisonAdaptor("board")
|
|
sensor := gpio.NewGroveRotaryDriver(board, "sensor", "0")
|
|
|
|
work := func() {
|
|
gobot.On(sensor.Event("data"), func(data interface{}) {
|
|
fmt.Println("sensor", data)
|
|
})
|
|
}
|
|
|
|
robot := gobot.NewRobot("sensorBot",
|
|
[]gobot.Connection{board},
|
|
[]gobot.Device{sensor},
|
|
work,
|
|
)
|
|
|
|
gbot.AddRobot(robot)
|
|
|
|
gbot.Start()
|
|
}
|