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.
↓ Download as a Fritzing project
Let’s link pot
with servo
to control the servo angle with the potentiometer.
Connect a servo to the Arduino board as shown on the scheme.
Link the VAL
pin of the pot
node to the VAL
pin of the servo
node.
Upload the patch to the board.
Turn the potentiometer knob, and watch the servo turns.
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.