gobot.io/x/gobot/v2@v2.1.0/examples/ollie.go (about) 1 //go:build example 2 // +build example 3 4 // 5 // Do not build by default. 6 7 package main 8 9 import ( 10 "os" 11 "time" 12 13 "gobot.io/x/gobot/v2" 14 "gobot.io/x/gobot/v2/platforms/ble" 15 "gobot.io/x/gobot/v2/platforms/sphero/ollie" 16 ) 17 18 func main() { 19 bleAdaptor := ble.NewClientAdaptor(os.Args[1]) 20 ollie := ollie.NewDriver(bleAdaptor) 21 22 work := func() { 23 gobot.Every(1*time.Second, func() { 24 r := uint8(gobot.Rand(255)) 25 g := uint8(gobot.Rand(255)) 26 b := uint8(gobot.Rand(255)) 27 ollie.SetRGB(r, g, b) 28 }) 29 } 30 31 robot := gobot.NewRobot("ollieBot", 32 []gobot.Connection{bleAdaptor}, 33 []gobot.Device{ollie}, 34 work, 35 ) 36 37 robot.Start() 38 }