Last active
January 3, 2016 10:09
-
-
Save stewart/8447541 to your computer and use it in GitHub Desktop.
cylon-sphero examples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Cylon = require('cylon'); | |
Cylon.robot({ | |
connection: { name: 'sphero', adaptor: 'sphero', port: '/dev/cu.Sphero-RRG-AMP-SPP' }, | |
device: { name: 'sphero', driver: 'sphero' }, | |
work: function(my) { | |
var on = false; | |
every((1).second(), function() { | |
// flash light | |
if (on) { | |
my.sphero.setColor("blue"); | |
on = false; | |
} else { | |
my.sphero.setColor('black'); | |
on = true; | |
} | |
}); | |
} | |
}).start(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Cylon = require('cylon'); | |
Cylon.robot({ | |
connection: { name: 'sphero', adaptor: 'sphero', port: '/dev/cu.Sphero-RRG-AMP-SPP' }, | |
device: { name: 'sphero', driver: 'sphero' }, | |
work: function(my) { | |
var on = false; | |
every((1).second(), function() { | |
// flash light | |
if (on) { | |
my.sphero.setColor("blue"); | |
on = false; | |
} else { | |
my.sphero.setColor('black'); | |
on = true; | |
} | |
// Roll in a random direction | |
my.sphero.roll(60, Math.floor(Math.random() * 360)); | |
}); | |
} | |
}).start(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Cylon = require('cylon'); | |
Cylon.robot({ | |
connection: { name: 'sphero', adaptor: 'sphero', port: '/dev/cu.Sphero-RRG-AMP-SPP' }, | |
device: { name: 'sphero', driver: 'sphero' }, | |
work: function(my) { | |
var on = false; | |
every((1).second(), function() { | |
// flash light | |
if (on) { | |
my.sphero.setColor("blue"); | |
on = false; | |
} else { | |
my.sphero.setColor('black'); | |
on = true; | |
} | |
// Roll in a random direction | |
my.sphero.roll(60, Math.floor(Math.random() * 360)); | |
}); | |
} | |
}); | |
// Tell Cylon we want it to spin up the API on port 4321 | |
Cylon.api({port: '4321'}) | |
// Start up Cylon API server | |
Cylon.start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment