This page has no translation to 中文 yet. The original English version is below. If you’d like to help, great! See how to translate a documentation page in the contribution guide.
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.

Servo

Screenshot of 106-servo

Controlling servos in XOD is just as easy as controlling LEDs. There is a node called servo. Find it in xod-dev/servo.

The servo node accepts a number in the range from 0.0 to 1.0 and maps it to the rated arm rotation limits of the servo motor.

Circuit #

Assembling servo to Uno

↓ Download as a Fritzing project

Exercise #

Let’s link pot with servo to control the servo angle with the potentiometer.

  1. Connect a servo to the Arduino board as shown on the scheme.

  2. Link the VAL pin of the pot node to the VAL pin of the servo node.

  3. Upload the patch to the board.

Turn the potentiometer knob, and watch the servo turns.

👆 Motors are power hogs #

If you wiggle the potentiometer fast enough you can encounter board reboots. It is because motors consume a lot of power when accelerate and if powered from the same power line as the microcontroller, the latter is left with no power at all.

To fight the effect in hardware, decouple digital parts of the circuit with capacitors and DC/DC converters. Use efficient power supplies along with (or instead of) your PC USB.

To deal with it in software, start and stop motors slowly. 206-fade gives one possible way to acheive it.

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.