#11. Controlling Servos

Note This is a web-version of a tutorial chapter embedded right into the XOD IDE. To get a better learning experience we recommend to install the desktop IDE or start the browser-based IDE, and you’ll see the same tutorial there.

Controlling servos in XOD is just as easy as controlling LEDs. There is a special node called servo. You will find it in xod/common-hardware.

Its PORT pin specifies the digital port on the Arduino that the servo is connected to. The pin VAL accepts values ranging from 0 to 1; it turns the servo shaft from 0 to 180°.

Patch

Test circuit

Note Although we don’t need the two LEDs used before in this particular lesson you can leave them as is on your own breadboard. We’ll use them again in later lessons. The same is true for any “disappearing” parts in next chapters.

Circuit

↓ Download as a Fritzing project

How-to

  1. Add a servo node to the patch
  2. Set its PORT pin value
  3. Link the VAL input to an output which provides value in range 0–1.

Screencast

Turn the potentiometer knob, and watch the servo turn, too!

Next lesson →

Found a typo or mistake? Want to improve the text? Edit this page on GitHub and open a pull request. If you have a complex proposal or you want to discuss the content, feel free to start a new thread on XOD forum.