31 lines
500 B
Go
31 lines
500 B
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
"time"
|
|
|
|
"gobot.io/x/gobot"
|
|
"gobot.io/x/gobot/platforms/ble"
|
|
"gobot.io/x/gobot/platforms/sphero/ollie"
|
|
)
|
|
|
|
func main() {
|
|
bleAdaptor := ble.NewClientAdaptor(os.Args[1])
|
|
ollie := ollie.NewDriver(bleAdaptor)
|
|
|
|
work := func() {
|
|
ollie.SetRGB(255, 0, 255)
|
|
gobot.Every(3*time.Second, func() {
|
|
ollie.Roll(40, uint16(gobot.Rand(360)))
|
|
})
|
|
}
|
|
|
|
robot := gobot.NewRobot("ollieBot",
|
|
[]gobot.Connection{bleAdaptor},
|
|
[]gobot.Device{ollie},
|
|
work,
|
|
)
|
|
|
|
robot.Start()
|
|
}
|