gobot.io/x/gobot/v2@v2.1.0/examples/ollie_crazy.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 ollieBot := ollie.NewDriver(bleAdaptor) 21 22 work := func() { 23 ollieBot.SetRGB(255, 0, 255) 24 gobot.Every(1*time.Second, func() { 25 // Ollie performs 'crazy-ollie' trick 26 ollieBot.SetRawMotorValues(ollie.Forward, uint8(255), ollie.Forward, uint8(255)) 27 }) 28 } 29 30 robot := gobot.NewRobot("ollieBot", 31 []gobot.Connection{bleAdaptor}, 32 []gobot.Device{ollieBot}, 33 work, 34 ) 35 36 robot.Start() 37 }