Preview:
#include <Servo.h>
Servo Serv1; //create a servo object named Serv1

//use a PWM pin (3,5,6,9,10,11)
int pinServo1=8;

void setup(){
Serv1.attach(pinServo1);
}

void loop(){
//move the servo 20 degrees
Serv1.write(20);
//allow enough time to move
delay(1000);
//move the servo 100 degrees
Serv1.write(100);
//allow enough time to move
delay(1000);
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter