We have yet to experiment with inputs but if you would like to control your motor, a potentiometer is a great choice and the Arduino editor has a example program for it. We are going to learn about the potentiometer in CIRC08, but we can get our feet wet with this type of input by modifying CIRC04.
Parts
You'll only need to add one part to this circuit: the blue trim potentiometer. You can find it in your box:
Breadboard Trim Potentiometer - 10k
If you'd like to buy an extra trimpot from the Adafruit store, click here!
Wire it such that the two outermost pins go to the power and ground rail. The inner pin should go to the Metro's analog pin 0. Note that we are using an analog pin instead of a digital pin this time, they are located on the left side of the Metro instead of the right side.
Metro Breadboard Diagram
Be careful - the Trim Potentiometer connects to the 3.3v input on the Metro, not the 5V rail.
Loading the example code
The code to load potentiometer control onto your revised CIRC04 is provided by Arduino under
File > Servo > Knob. After loading the sketch, compile and upload it to your metro. Move the potentiometer left and right, you should see the servo move with it.
Self-Timing
While it is easy to control a servo using the Metro's included library, sometimes it is fun to figure out how to program something yourself. Try it! Remember that we're controlling the pulse directly so you could use this method to control servos on any of the Metro's 20 available pins (you need to highly optimize this code before doing that).
Other fun servo ideas
Servos can be used to do all sorts of things. The Adafruit Learning System is a great resource to find a fun project with servos.
Here are a few of our favorites:
Text editor powered by tinymce.