Control Speed of Hobby Servo With Potentiometer.

by ChristopherH158 in Circuits > Arduino

155 Views, 2 Favorites, 0 Comments

Control Speed of Hobby Servo With Potentiometer.

IMG_20230330_145802638.jpg

I needed a way to control the speed at which a servo would swing without changing code. Googling "controlling a servo" will bring up a dozen examples of how to control position but did not find one that provided code to include a potentiometer. I have played with Arduino for projects for years and could always find code that someone else had done. This was the first time I have used what I had learned by looking at other peoples code to implement something I needed. Don't expect a huge example of clever programing this technique has been used hundreds of time for a hundred different things involving a "pot". Doing this was way quicker to write then the time I spent looking for an example by someone else. I just hope some Googles "controlling speed of a servo" and this pops up.

This uses a Arduino Nano to control a 20 kg hobby Servo. A servo this size it to big to use the Nano's 5v output to control so I used a 1000mah 2s Lipo which puts out 7.4 volts.


Supplies

I used items from Amazon

1ea. Nano board

1ea 4" bread board

1ea 10k potentiometer

1ea 20kg hobby Servo

1 ea 1000mah 2s Lipo battery and charger

Hook up wire as needed 20 gage

Untitled Sketch_bb.png

The Arduino is annotated so you should be able to figure out what is going on. and the diagram should be self explanatory.