hybridgroup.gobot/examples/bleclient_ollie_roll.go

40 lines
653 B
Go

//go:build example
// +build example
//
// Do not build by default.
//nolint:gosec // ok here
package main
import (
"os"
"time"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/drivers/ble/sphero"
"gobot.io/x/gobot/v2/platforms/bleclient"
)
func main() {
bleAdaptor := bleclient.NewAdaptor(os.Args[1])
ollie := sphero.NewOllieDriver(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,
)
if err := robot.Start(); err != nil {
panic(err)
}
}