Skip to content

Instantly share code, notes, and snippets.

@astagi
Last active January 7, 2016 09:42
Show Gist options
  • Save astagi/7a3deefa7818a760ea9d to your computer and use it in GitHub Desktop.
Save astagi/7a3deefa7818a760ea9d to your computer and use it in GitHub Desktop.
Programming Sphero BB-8

Programming Sphero BB-8

Install dependencies

$ sudo npm install cylon cylon-ble -g
$ npm install sphero noble

Get your BB-8 UUID

$ cylon-ble-scan

You should get an output like this:

Starting scan.
  Peripheral discovered!
  Name: BB-CC91
  UUID: efbec196e7124feb85e2dbb272fb0652
  rssi: -34

Change device UUID accordingly

var sphero = require("sphero"),
  bb8 = sphero("Your-BB-8-UUID");

Start the app

$ node app.js

For more about sphero.js visit https://github.com/orbotix/sphero.js

var sphero = require("sphero"),
bb8 = sphero("efbec196e7124feb85e2dbb272fb0652"); //Change this accordingly
bb8.connect(function() {
console.log("You BB-8 is now connected!")
setInterval(function() {
bb8.color({
red: Math.floor(Math.random() * 255),
green: Math.floor(Math.random() * 255),
blue: Math.floor(Math.random() * 255)
});
bb8.roll(0, Math.floor(Math.random() * 360));
}, 500);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment