Updated servo examples to include the new optional range param.
This commit is contained in:
parent
dcec9e0ffe
commit
e549f6e0a6
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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:
|
||||
|
||||
|
|
Loading…
Reference in New Issue