Create a gist now

Instantly share code, notes, and snippets.

Turn your Sphero into a twitter watchbot
var Cylon = require('cylon');
var Twitter = require('twitter');
var iod = require('iod-node')
var iodclient= new iod.IODClient('','<yourapikey>')
var twitterclient = new Twitter({
consumer_key: '<yourconsumerkey>',
consumer_secret: '<yourconsumersecret>',
access_token_key: '<youraccesstoken>',
access_token_secret: '<youraccesstokensecret>'
function watchdog(my){'statuses/filter', {track: 'sphero'}, function(stream) {
stream.on('data', function(tweet) {
var data= {'text':tweet.text}'analyzesentiment',function(err,resp,body){
var sentiment = body["aggregate"]["sentiment"];
my.sphero.roll(0,180) // Everytime the sphero will spin half a rotation
if (sentiment=="positive"){ my.sphero.setRGB(0x01DF74) } //Green
else if (sentiment == "negative"){ my.sphero.setRGB(0xFF3300) } //Red
else{ my.sphero.setRGB(0x0066FF) } //Blue for neutral
after((1).seconds(), function() { // Return to white
stream.on('error', function(error) {
throw error;
connections: {
sphero: { adaptor: 'sphero', port: '/dev/cu.Sphero-YBW-AMP-SPP' }
devices: {
sphero: { driver: 'sphero' }
work: watchdog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment