gobot.io/x/gobot@v1.16.0/examples/edison_grove_rotary_sensor.go (about) 1 // +build example 2 // 3 // Do not build by default. 4 5 package main 6 7 import ( 8 "fmt" 9 10 "gobot.io/x/gobot" 11 "gobot.io/x/gobot/drivers/aio" 12 "gobot.io/x/gobot/platforms/intel-iot/edison" 13 ) 14 15 func main() { 16 board := edison.NewAdaptor() 17 sensor := aio.NewGroveRotaryDriver(board, "0") 18 19 work := func() { 20 sensor.On(aio.Data, func(data interface{}) { 21 fmt.Println("sensor", data) 22 }) 23 } 24 25 robot := gobot.NewRobot("sensorBot", 26 []gobot.Connection{board}, 27 []gobot.Device{sensor}, 28 work, 29 ) 30 31 robot.Start() 32 }