2013-11-26 08:06:55 +08:00
|
|
|
var Cylon = require('../..');
|
|
|
|
|
|
|
|
Cylon.robot({
|
|
|
|
connection: { name: 'arduino', adaptor: 'firmata', port: '/dev/ttyACM0' },
|
|
|
|
device: { name: 'motor', driver: 'motor', pin: 3 },
|
|
|
|
|
|
|
|
work: function(my) {
|
|
|
|
var speed = 0;
|
|
|
|
var increment = 5;
|
|
|
|
|
|
|
|
every(0.05.seconds(), function() {
|
|
|
|
speed += increment;
|
|
|
|
my.motor.speed(speed);
|
|
|
|
|
2014-01-04 09:18:09 +08:00
|
|
|
console.log("Current Speed: " + (my.motor.currentSpeed()));
|
2013-11-26 08:06:55 +08:00
|
|
|
|
|
|
|
if ((speed === 0) || (speed === 255)) { increment = -increment; }
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}).start();
|