Controlling the servo with a potentiometer or another analog sensor is easy. However, what if we want to make some complex movements with servos?
On the patch board, you see
servo-device. This node defines a servo for the further usage: the port, minimum, and maximum pulse widths which correspond to the operating limits of the servo.
servo-device node links to nodes that work with servos:
rotate-slow in this example. The
rotate-slow node rotates the servo to the angle specified in
VAL with the
RATE speed when a
DO pulse is received. You may chain these nodes to make a sequential movement.
You may notice that
MUX pins. It’s another custom type called
mutex that allows only one node to act at the same time.
This program rotates the servo to the maximum angle slowly and then turn it back twice as fast on a button press. The button is ignored until rotation completes.
Upload the program and check it out.
Let’s change the servo trajectory.
Press the button and see how the servo fulfills your order.
xod-dev/servo library also contains a
rotate node. The main difference between it and
rotate-slow that it rotates the servo immediately ignoring
And if you wonder how the simple
servo node used in the previous chapter works: under the hood, it is a trivial composition of
rotate with a few terminals exposed to you. Simple nodes (also known as quickstart nodes) are enough for basic applications and when you need more, you use raw device nodes along with action nodes like you do in this chapter.
This idiom is applicable to other hardware as well.