19 lines
497 B
JavaScript
19 lines
497 B
JavaScript
|
var Cylon = require('../..');
|
||
|
|
||
|
Cylon.robot({
|
||
|
connection: { name: 'raspi', adaptor: 'raspi', port: '/dev/ttyACM0' },
|
||
|
device: { name: 'servo', driver: 'servo', pin: 11 },
|
||
|
|
||
|
work: function(my) {
|
||
|
var angle = 30;
|
||
|
var increment = 40;
|
||
|
|
||
|
every(1..seconds(), function() {
|
||
|
angle += increment;
|
||
|
my.servo.angle(angle);
|
||
|
Logger.info("Current Angle: " + (my.servo.currentAngle()));
|
||
|
if ((angle === 30) || (angle === 150)) { increment = -increment; }
|
||
|
});
|
||
|
}
|
||
|
}).start();
|