int servoPin = 8; //this is the pin where the servo will be connected, change for any digital pin int servoPos = 2400; //this value will be to set the servo position //values range from 500 to 2500, and represent from 0 - 180 degrees. //is actually time in micro-seconds to determine pulse size for the servo void setup(){ //define the pins as an output pinMode(servoPin,OUTPUT); } void loop(){ //in this case we are using a for loop to ensure that we hit the position that we want to reach with the servo quickly //one pulse will move the servo only a little ways towards it's final destination, so we are doing 20 for(int i=0;i<20;i++){ digitalWrite(servoPin,HIGH); //turn on the servo pin, i.e send 5V delayMicroseconds(servoPos); //delay for the pulse length set in declarations digitalWrite(servoPin,LOW); //turn servo pin back off to end the pulse delay(20); //you need to wait 15 - 20 milli-seconds between pulses, no more, no less, or the frequency will be too off //this is important to know if you want to do something fancier within the code, like maybe pulse a few servo in the same loop //you will need to compensate the delay to address the time it would take to go through the extra lines of code. //it is usually easier to do them one at a time. } }