Skip to content

Instantly share code, notes, and snippets.

@mattdsteele
Created September 20, 2014 22:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattdsteele/8757323590e049a79de8 to your computer and use it in GitHub Desktop.
Save mattdsteele/8757323590e049a79de8 to your computer and use it in GitHub Desktop.
Sphero!
var spheron = require('spheron'),
s = spheron.sphero().resetTimeout(true).requestAcknowledgement(true);
var spheroPort = '/dev/rfcomm0';
var COLORS = spheron.toolbelt.COLORS;
s.on('open', function() {
var repeat = true;
var police = function(delay1, delay2) {
s.setRGB(0x000000, false);
setTimeout(function() {
s.setRGB(0x0000FF);
}, delay1);
setTimeout(function() {
s.setRGB(0x000000, false);
}, delay1*2);
setTimeout(function() {
s.setRGB(0x0000FF, false);
}, delay1*3);
setTimeout(function() {
s.setRGB(0x000000, false);
}, delay1*4);
setTimeout(function() {
s.setRGB(0xFF0000, false);
}, delay1*5);
setTimeout(function() {
s.setRGB(0x000000, false);
}, delay1*6);
setTimeout(function() {
s.setRGB(0xFF0000, false);
}, delay1*7);
setTimeout(function() {
s.setRGB(0x000000, false);
}, delay1*8);
};
police(100, 200);
setTimeout(function() {
s.roll(100, 100, 1);
}, 1000);
setTimeout(function() {
s.roll(0, 100, 0);
}, 2000);
setTimeout(function() {
s.roll(100, 280, 1);
}, 3000);
setTimeout(function() {
s.roll(0, 280, 0);
}, 4000);
});
s.open(spheroPort);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment