diff --git a/examples/servo/servo.coffee b/examples/servo/servo.coffee index 527a1b0..d192e04 100644 --- a/examples/servo/servo.coffee +++ b/examples/servo/servo.coffee @@ -1,8 +1,15 @@ Cylon = require '../..' Cylon.robot - connection: { name: 'arduino', adaptor: 'firmata', port: '/dev/ttyACM0' } - device: { name: 'servo', driver: 'servo', pin: 3 } + connection: + 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) -> angle = 30 diff --git a/examples/servo/servo.js b/examples/servo/servo.js index 4be79a0..52698c2 100644 --- a/examples/servo/servo.js +++ b/examples/servo/servo.js @@ -2,7 +2,7 @@ var Cylon = require('../..'); Cylon.robot({ 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) { var angle = 30; diff --git a/examples/servo/servo.litcoffee b/examples/servo/servo.litcoffee index 017643a..cb980d4 100644 --- a/examples/servo/servo.litcoffee +++ b/examples/servo/servo.litcoffee @@ -15,10 +15,16 @@ Now we can start defining our robot: Cylon.robot 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' } - device: { name: 'servo', driver: 'servo', pin: 3 } + connection: + 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: