package main
import (
"fmt"
"os"
"gobot.io/x/gobot"
"gobot.io/x/gobot/platforms/ble"
"gobot.io/x/gobot/platforms/sphero/sprkplus"
)
func main() {
bleAdaptor := ble.NewClientAdaptor(os.Args[1])
ball := sprkplus.NewDriver(bleAdaptor)
work := func() {
ball.On("collision", func(data interface{}) {
fmt.Printf("collision detected = %+v \n", data)
ball.SetRGB(255, 0, 0)
})
ball.SetRGB(0, 255, 0)
ball.Roll(80, 0)
}
robot := gobot.NewRobot("sprkplus",
[]gobot.Connection{bleAdaptor},
[]gobot.Device{ball},
work,
)
robot.Start()
}