Introduction
- Servo
- Arduino Mega 2560
- HookUp Wires
Servo

Figure 1: Servo
- It is small and cost-effective.
- It is used for small robotics and radio controls.
Connection
- The servo first pin can be connected to the Gnd
- The second pin can be connected to the Vcc
- The Third pin can be connected to the digital pin 09 of the Arduino Mega 2560.
Programming
- #include <Servo.h>
- Servo myservo; // create servo object to control a servo
- void setup()
- {
- myservo.attach(9); // attaches the servo on pin 9 to the servo object
- }
- void loop(){
- myservo.write(0); // sets the servo at 0 degree position
- delay(1000); // waits for the servo to get there
- myservo.write(90); // sets the servo at 90 degree position
- delay(1000); // waits for the servo to get there
- myservo.write(180); // sets the servo at 180 degree position
- delay(1000); // waits for the servo to get there
- myservo.write(90); // sets the servo at 90 degree position
- delay(1000); // waits for the servo to get there
- }
Explanation
- The servo can work in the condition of the degree.
- It can first rotate in the 0 degree
- Then 90, 180, and it will automatically return to 90 degree.
Output:

Figure 2: Output
Read more articles on Arduino:

Sr KarthigaPosted Mar 27, 2016, 8:59 PM
Thank you prashant verma sir
Prashant VermaPosted Mar 10, 2016, 2:10 AM
nice
Sr KarthigaPosted Feb 29, 2016, 7:48 PM
thank you asfend sir
Asfend YarPosted Feb 29, 2016, 2:20 PM
nice
Sr KarthigaPosted Feb 23, 2016, 7:39 PM
thank you santhakumar sir
Sr KarthigaPosted Feb 23, 2016, 7:39 PM
Thank you shubham sir
Santhakumar MunuswamyPosted Feb 23, 2016, 2:26 PM
Thanks for nice work
Shubham KumarPosted Feb 22, 2016, 12:40 AM
nice Article
Sr KarthigaPosted Feb 21, 2016, 11:04 PM
Thank you saineshwar sir
Saineshwar BageriPosted Feb 21, 2016, 11:03 PM
Nice one
Sr KarthigaPosted Feb 21, 2016, 7:51 PM
Thank you gowtham sir
Sr KarthigaPosted Feb 21, 2016, 7:51 PM
Thank you sibeesh sir
Gowtham KPosted Feb 21, 2016, 11:51 AM
Good One
Sibeesh VenuPosted Feb 21, 2016, 9:25 AM
Nice Share
Sr KarthigaPosted Feb 20, 2016, 7:37 PM
Thank you kumaresh sir
Kumaresh RajalingamPosted Feb 20, 2016, 6:58 PM
Very Nice