gobot.io/x/gobot/v2@v2.1.0/platforms/sphero/ollie/README.md (about) 1 # Sphero Ollie 2 3 The Sphero Ollie is a toy robot from Sphero that is controlled using Bluetooth LE. For more information, go to [http://www.sphero.com/ollie](http://www.sphero.com/ollie) 4 5 ## How to Install 6 7 ``` 8 go get -d -u gobot.io/x/gobot/v2/... 9 ``` 10 11 ## How to Use 12 13 ```go 14 package main 15 16 import ( 17 "os" 18 "time" 19 20 "gobot.io/x/gobot/v2" 21 "gobot.io/x/gobot/v2/platforms/ble" 22 "gobot.io/x/gobot/v2/platforms/sphero/ollie" 23 ) 24 25 func main() { 26 bleAdaptor := ble.NewClientAdaptor(os.Args[1]) 27 ollie := ollie.NewDriver(bleAdaptor) 28 29 work := func() { 30 gobot.Every(1*time.Second, func() { 31 r := uint8(gobot.Rand(255)) 32 g := uint8(gobot.Rand(255)) 33 b := uint8(gobot.Rand(255)) 34 ollie.SetRGB(r, g, b) 35 }) 36 } 37 38 robot := gobot.NewRobot("ollieBot", 39 []gobot.Connection{bleAdaptor}, 40 []gobot.Device{ollie}, 41 work, 42 ) 43 44 robot.Start() 45 } 46 ``` 47 48 ## How to Connect 49 50 The Sphero Ollie is a Bluetooth LE device. 51 52 You need to know the BLE ID of the Ollie you want to connect to. The Gobot BLE client adaptor also lets you connect by friendly name, aka "2B-1247". 53 54 ### OSX 55 56 To run any of the Gobot BLE code you must use the `GODEBUG=cgocheck=0` flag in order to get around some of the issues in the CGo-based implementation. 57 58 If you connect by name, then you do not need to worry about the Bluetooth LE ID. However, if you want to connect by ID, OS X uses its own Bluetooth ID system which is different from the IDs used on Linux. The code calls thru the XPC interfaces provided by OSX, so as a result does not need to run under sudo. 59 60 For example: 61 62 GODEBUG=cgocheck=0 go run examples/ollie.go 2B-1247 63 64 ### Ubuntu 65 66 On Linux the BLE code will need to run as a root user account. The easiest way to accomplish this is probably to use `go build` to build your program, and then to run the requesting executable using `sudo`. 67 68 For example: 69 70 go build examples/ollie.go 71 sudo ./minidrone 2B-1247 72 73 ### Windows 74 75 Hopefully coming soon...