Updated servo examples to use a limit range of motion instead of full 180.
This commit is contained in:
parent
402edc1a1e
commit
8f7e1d0193
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue