1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-04-27 13:48:56 +08:00
deadprogram 8fa839081f [ble] Ollie example color cycles
Signed-off-by: deadprogram <ron@hybridgroup.com>
2016-07-10 12:08:34 -06:00

36 lines
606 B
Go

package main
import (
"os"
"time"
"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/platforms/ble"
)
func main() {
gbot := gobot.NewGobot()
bleAdaptor := ble.NewBLEClientAdaptor("ble", os.Args[1])
ollie := ble.NewSpheroOllieDriver(bleAdaptor, "ollie")
work := func() {
gobot.Every(1*time.Second, func() {
r := uint8(gobot.Rand(255))
g := uint8(gobot.Rand(255))
b := uint8(gobot.Rand(255))
ollie.SetRGB(r, g, b)
})
}
robot := gobot.NewRobot("ollieBot",
[]gobot.Connection{bleAdaptor},
[]gobot.Device{ollie},
work,
)
gbot.AddRobot(robot)
gbot.Start()
}