Files
xod/docs/tutorial/11-servo/README.md
2017-10-10 16:34:38 +03:00

48 lines
1.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: Controlling Servos
---
# #11. Controlling Servos
<div class="ui segment note">
<span class="ui ribbon label">Note</span>
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
<a href="/downloads/">desktop IDE</a> or start the
<a href="/ide/">browser-based IDE</a>, and youll see the same tutorial there.
</div>
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](./patch.png)
## Test circuit
<div class="ui segment note">
<span class="ui ribbon label">Note</span>
Although we dont need the two LEDs used before in this particular lesson you
can leave them as is on your own breadboard. Well use them again in later
lessons. The same is true for any “disappearing” parts in next chapters.
</div>
![Circuit](./circuit.fz.png)
[↓ Download as a Fritzing project](./circuit.fzz)
## 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 01.
![Screencast](./screencast.gif)
Turn the potentiometer knob, and watch the servo turn, too!
[Next lesson →](../12-help/)