Adding servo driver example.

This commit is contained in:
Edgar O Silva 2013-10-30 20:41:47 -06:00
parent ea472f9e12
commit bf86c6f414
1 changed files with 20 additions and 0 deletions

20
examples/servo.coffee Normal file
View File

@ -0,0 +1,20 @@
Cylon = require('..')
# Initialize the robot
Cylon.robot
connection:
name: 'arduino', adaptor: 'firmata', port: '/dev/ttyACM0'
device:
name: 'servo', driver: 'servo', pin: 3
work: (my) ->
angle = 0
increment = 90
every 1.seconds(), ->
angle += increment
my.servo.angle(angle)
console.log("Current Angle => #{ my.servo.currentAngle() }")
increment = -increment if (angle is 0) or (angle is 180)
.start()