Previous

This is the 21st example in a series of examples for arduino beginners. For more examples click these buttons or select a example from the grid at the bottom.

Next

Description

In this 21st example in our arduino for beginners examples, we control a RC servo motor. RC servo motors are used in variety of applications ranging from robotics to RC planes etc. In this example a standard servo is used .

Code

#include <Servo.h>
Servo myservo;
int pos = 0;
void setup()
{
myservo.attach(9);
}

void loop()
{
for(pos = 0; pos <= 180; pos += 1) { myservo.write(pos); delay(15); } for(pos = 180; pos>=0; pos-=1)
{
myservo.write(pos);
delay(15);
}
}

Pictures / Video

Arduino For Beginners - Servo Motor Control
Arduino For Beginners - Servo Motor Control
Arduino For Beginners - Servo Motor Control

Files

Arduino SketchFritzing File

Share This

Other Examples

| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |

Other Learning Resources