gobot.io/x/gobot@v1.16.0/platforms/sphero/sprkplus/README.md (about) 1 # Sphero SPRK+ 2 3 The Sphero SPRK+ is a toy robot from Sphero that is controlled using Bluetooth LE. For more information, go to [http://www.sphero.com/sprk-plus](http://www.sphero.com/sprk-plus) 4 5 ## How to Install 6 7 ``` 8 go get -d -u gobot.io/x/gobot/... 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" 21 "gobot.io/x/gobot/platforms/ble" 22 "gobot.io/x/gobot/platforms/sphero/sprkplus" 23 ) 24 25 func main() { 26 bleAdaptor := ble.NewClientAdaptor(os.Args[1]) 27 sprk := sprkplus.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 sprk.SetRGB(r, g, b) 35 }) 36 } 37 38 robot := gobot.NewRobot("sprk", 39 []gobot.Connection{bleAdaptor}, 40 []gobot.Device{sprk}, 41 work, 42 ) 43 44 robot.Start() 45 } 46 ``` 47 48 ## How to Connect 49 50 The Sphero SPRK+ is a Bluetooth LE device. 51 52 You need to know the BLE ID of the SPRK+ you want to connect to. The Gobot BLE client adaptor also lets you connect by friendly name, aka "SK-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/sprkplus.go SK-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/sprkplus.go 71 sudo ./sprkplus SK-1247 72 73 ### Windows 74 75 Hopefully coming soon...