gobot.io/x/gobot@v1.16.0/examples/ollie_crazy.go (about)

     1  // +build example
     2  //
     3  // Do not build by default.
     4  
     5  package main
     6  
     7  import (
     8  	"os"
     9  	"time"
    10  
    11  	"gobot.io/x/gobot"
    12  	"gobot.io/x/gobot/platforms/ble"
    13  	"gobot.io/x/gobot/platforms/sphero/ollie"
    14  )
    15  
    16  func main() {
    17  	bleAdaptor := ble.NewClientAdaptor(os.Args[1])
    18  	ollieBot := ollie.NewDriver(bleAdaptor)
    19  
    20  	work := func() {
    21  		ollieBot.SetRGB(255, 0, 255)
    22  		gobot.Every(1*time.Second, func() {
    23  			// Ollie performs 'crazy-ollie' trick
    24  			ollieBot.SetRawMotorValues(ollie.Forward, uint8(255), ollie.Forward, uint8(255))
    25  		})
    26  	}
    27  
    28  	robot := gobot.NewRobot("ollieBot",
    29  		[]gobot.Connection{bleAdaptor},
    30  		[]gobot.Device{ollieBot},
    31  		work,
    32  	)
    33  
    34  	robot.Start()
    35  }