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