2023-05-20 20:25:21 +08:00
|
|
|
//go:build example
|
2017-12-26 16:30:59 +08:00
|
|
|
// +build example
|
2023-05-20 20:25:21 +08:00
|
|
|
|
2017-12-26 16:30:59 +08:00
|
|
|
//
|
|
|
|
// Do not build by default.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"time"
|
|
|
|
|
2023-05-20 20:25:21 +08:00
|
|
|
"gobot.io/x/gobot/v2"
|
|
|
|
"gobot.io/x/gobot/v2/platforms/ble"
|
|
|
|
"gobot.io/x/gobot/v2/platforms/sphero/ollie"
|
2017-12-26 16:30:59 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
bleAdaptor := ble.NewClientAdaptor(os.Args[1])
|
|
|
|
ollieBot := ollie.NewDriver(bleAdaptor)
|
|
|
|
|
|
|
|
work := func() {
|
|
|
|
ollieBot.SetRGB(255, 0, 255)
|
|
|
|
gobot.Every(1*time.Second, func() {
|
|
|
|
// Ollie performs 'crazy-ollie' trick
|
|
|
|
ollieBot.SetRawMotorValues(ollie.Forward, uint8(255), ollie.Forward, uint8(255))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
robot := gobot.NewRobot("ollieBot",
|
|
|
|
[]gobot.Connection{bleAdaptor},
|
|
|
|
[]gobot.Device{ollieBot},
|
|
|
|
work,
|
|
|
|
)
|
|
|
|
|
|
|
|
robot.Start()
|
|
|
|
}
|