1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-04-26 13:48:49 +08:00
hybridgroup.gobot/examples/bb8-collision.go
Marc-Antoine Ruel 50d5869808 Fix go test ./...
Make all examples to not be built by default by adding the build tag 'example'.
Some files were automatically reformatted by goimports upon saving.
2017-03-13 11:01:39 -04:00

40 lines
589 B
Go

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