gobot.io/x/gobot/v2@v2.1.0/examples/ollie_roll.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 ollie.SetRGB(255, 0, 255) 24 gobot.Every(3*time.Second, func() { 25 ollie.Roll(40, uint16(gobot.Rand(360))) 26 }) 27 } 28 29 robot := gobot.NewRobot("ollieBot", 30 []gobot.Connection{bleAdaptor}, 31 []gobot.Device{ollie}, 32 work, 33 ) 34 35 robot.Start() 36 }