Tutorials

Servo with Potentiometer
The Arduino environment comes with an example for controlling a servo with a potentiometer called “Knob” found in File->Examples->Servo->Knob. This is the easiest way to control a servo from the Arduino. Here’s a copy of that if you can’t find it:

Knob Servo Arduino Sketch
Servo Library Documentation

Important Servo Functions
attach() – Attach the Servo variable to a pin.
write() – Writes a value to the servo, controlling the shaft accordingly.

That example uses the servo library, but controlling a servo can also be done manually without the library and with a lot more code. This is a much more difficult example, but useful if the Arduino servo library isn’t working for you. The following example is slightly modified from the example hosted at ITP here.

Arduino Sketch
Notes on Implementing the Sketch

Important Functions
Serial.println() – http://arduino.cc/en/Serial/Println
analogRead() – http://arduino.cc/en/Reference/AnalogRead
millis() – http://arduino.cc/en/Reference/Millis
pinMode() – http://arduino.cc/en/Reference/PinMode
map() – http://arduino.cc/en/Reference/Map
delayMicroseconds() – http://arduino.cc/en/Reference/DelayMicroseconds

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>