Updated servo examples to include the new optional range param.

This commit is contained in:
Edgar O Silva 2014-01-19 23:19:49 -06:00
parent dcec9e0ffe
commit e549f6e0a6
3 changed files with 19 additions and 6 deletions

View File

@ -1,8 +1,15 @@
Cylon = require '../..' Cylon = require '../..'
Cylon.robot Cylon.robot
connection: { name: 'arduino', adaptor: 'firmata', port: '/dev/ttyACM0' } connection:
device: { name: 'servo', driver: 'servo', pin: 3 } name: 'arduino', adaptor: 'firmata', port: '/dev/ttyACM0'
# when declaring the servo driver you can add an optional range param
# (defaults to min: 30 max 150). This param sets limits for the angle,
# so sot he servo can't be damaged if it cannot move in the full 0-180
# range, most servos are not capable of this.
device:
name: 'servo', driver: 'servo', pin: 3, range: { min: 30, max: 150}
work: (my) -> work: (my) ->
angle = 30 angle = 30

View File

@ -2,7 +2,7 @@ var Cylon = require('../..');
Cylon.robot({ Cylon.robot({
connection: { name: 'arduino', adaptor: 'firmata', port: '/dev/ttyACM0' }, connection: { name: 'arduino', adaptor: 'firmata', port: '/dev/ttyACM0' },
device: { name: 'servo', driver: 'servo', pin: 3 }, device: { name: 'servo', driver: 'servo', pin: 3, range: { min: 30, max: 150 } },
work: function(my) { work: function(my) {
var angle = 30; var angle = 30;

View File

@ -15,10 +15,16 @@ Now we can start defining our robot:
Cylon.robot Cylon.robot
We'll be connecting to an Ardunio, using the Firmata protocol, and a servo We'll be connecting to an Ardunio, using the Firmata protocol, and a servo
attached to the Arduino on pin 3. attached to the Arduino on pin 3. We have the option to pass an extra 'range'
param to the device, this param sets the min and max angle values. By default
this is set to min: 30, max: 150 to prevent damaging the servo when giving it
an angle outside the range it can cover.
connection: { name: 'arduino', adaptor: 'firmata', port: '/dev/ttyACM0' } connection:
device: { name: 'servo', driver: 'servo', pin: 3 } name: 'arduino', adaptor: 'firmata', port: '/dev/ttyACM0'
device:
name: 'servo', driver: 'servo', pin: 3, range: { low: 30, high: 150}
We'll start defining the work for our robot next: We'll start defining the work for our robot next: