Updated servo examples to use a limit range of motion instead of full 180.

This commit is contained in:
Edgar O Silva 2013-11-27 18:23:17 -06:00
parent 402edc1a1e
commit 8f7e1d0193
2 changed files with 6 additions and 6 deletions

View File

@ -11,12 +11,12 @@ Cylon.robot
work: (my) ->
# we do our thing here
work: (my) ->
angle = 0
increment = 90
angle = 30
increment = 40
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)
increment = -increment if (angle is 30) or (angle is 150)
.start()

View File

@ -9,12 +9,12 @@ Cylon.robot
name: 'servo', driver: 'servo', pin: 3
work: (my) ->
angle = 0
increment = 90
angle = 30
increment = 40
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)
increment = -increment if (angle is 30) or (angle is 150)
.start()