hybridgroup.gobot/examples/edison_grove_rotary_sensor.go

33 lines
542 B
Go

package main
import (
"fmt"
"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/drivers/gpio"
"github.com/hybridgroup/gobot/platforms/intel-iot/edison"
)
func main() {
gbot := gobot.NewMaster()
board := edison.NewAdaptor()
sensor := gpio.NewGroveRotaryDriver(board, "0")
work := func() {
sensor.On(gpio.Data, func(data interface{}) {
fmt.Println("sensor", data)
})
}
robot := gobot.NewRobot("sensorBot",
[]gobot.Connection{board},
[]gobot.Device{sensor},
work,
)
gbot.AddRobot(robot)
gbot.Start()
}