"The power wire is typically red, and should be connected to the 5V pin on the Arduino board. The ground wire is typically black or brown and should be connected to a ground pin on the Arduino board. The signal pin is typically yellow, orange or white and should be connected to a digital pin on the Arduino board. Note that servos draw considerable power, so if you need to drive more than one or two, you'll probably need to power them from a separate supply (i.e. not the +5V pin on your Arduino). Be sure to connect the grounds of the Arduino and external power supply together." from Arduino's website.
Servo are used in many objects/devices such as game controller, robots, helicopter (toy remote control), etc.
Tutorial
Materials:
1. Arduino board
2. Breadboard
3. Jumper wires
4. Potentiometer
5. Servo
6. 9 volt battery (optional)
Anyway, after taking that video (above), I tried connecting the 9 volt battery to the circuit to give it more power, and it worked really well. I'm excited to be making something that reacts to the command!
/* Use a potentiometer(ajustable resistor) to control servo position
* Copyright John Yu
* detail project see http://osoyoo.com/?p=172
*/
#include <Servo.h>
Servo servo_obj; // create servo object to control a servo
int control_put = 0; // define A0 port to receive control signal from potentiometer
int position; // variable to read the value from the analog pin
void setup()
{
servo_obj.attach(7); // attaches the servo on pin 7 to the servo object
}
void loop()
{
position = map(analogRead(control_put), 0, 1023, 0, 179); //get input signal from A0,convert it into angle value
servo_obj.write(position); // sets the servo position according to the scaled value
delay(25);
}