Added servo example for Raspi.

This commit is contained in:
Edgar O Silva 2013-11-27 11:42:25 -06:00
parent f6a2b246d2
commit e40289b3ea
1 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,22 @@
Cylon = require('..')
# Initialize the robot
Cylon.robot
connection:
name: 'raspi', adaptor: 'raspi', port: '/dev/ttyACM0'
device:
name: 'servo', driver: 'servo', pin: 11
work: (my) ->
# we do our thing here
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()