One of the uses we have in store for arduino is to cut down on the menial tasks we have to do to make electronics kits, recreating oomlout's RECO is a prime priority so we thought we'd first learn how to use servos and motors.
Servos are easiest as they're low power and can be run directly from the board using a single pin. We also used a potentiometer on another pin to allow control. The sketch we used is
CodeColon Select all
// Controlling a servo position using a potentiometer (variable resistor)
// by Michal Rinott <http://people.interaction-ivrea.it/m.rinott>
Servo myservo; // create servo object to control a servo
int potpin = 0; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin
myservo.attach(9); // attaches the servo on pin 9 to the servo object
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
myservo.write(val); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
The code and the board layout can be found here: http://arduino.cc/en/Tutorial/Knob
I have some video of the results and for something that is so simple it is rather cool!