Skip to content

Instantly share code, notes, and snippets.

@netomarin
Created February 14, 2019 20:56
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 netomarin/182916e8f8e237635df124726913029a to your computer and use it in GitHub Desktop.
Save netomarin/182916e8f8e237635df124726913029a to your computer and use it in GitHub Desktop.
Basic Sphero connection demo using their JavaScript API
var sphero = require("sphero"),
sprk = sphero("EA:FE:34:55:2A:E0"); // change BLE address accordingly
sprk.connect(function() {
// roll Sphero in a random direction, changing direction every second
setInterval(function() {
var direction = Math.floor(Math.random() * 360);
sprk.roll(150, direction);
}, 1000);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment