Skip to content

Instantly share code, notes, and snippets.

@dimorphic
Forked from jakswa/bb8_sphero.md
Created December 18, 2015 12:19
Show Gist options
  • Save dimorphic/a0dc95c68a9eea53d72e to your computer and use it in GitHub Desktop.
Save dimorphic/a0dc95c68a9eea53d72e to your computer and use it in GitHub Desktop.

Install needed node packages:

npm install -g cylon-ble
npm install cylon cylon-ollie

First scan for your BB8 (the device name should contain BB in it):

> sudo cylon-ble-scan
[...]
Peripheral discovered!
  Name: BB-3B29
  UUID: 161205d4f3a04149a1ea82762d30fd86
  rssi: -63

Then take its UUID and plop it in the bluetooth section of this, and you can run it:

var Cylon = require('cylon');

Cylon.robot({
  connections: {
    bluetooth: { adaptor: 'central', uuid: '161205d4f3a04149a1ea82762d30fd86', module: 'cylon-ble'}
  },

  devices: {
    ollie: { driver: 'ollie'}
  },

  work: function(my) {
    my.ollie.wake(function(err, data){
      console.log("wake");

      after(200, function() {
        my.ollie.setRGB(0x00FFFF);
      });

      after(500, function() {
        my.ollie.setRGB(0xFF0000);
        my.ollie.roll(60, 0, 1);

        after(1000, function(){
          my.ollie.roll(60, 90, 1);

          after(1000, function(){
            my.ollie.stop();
          });
        });
      });
    });
  }
}).start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment