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, 4:59 PM EDT
Thank you prashant verma sir
Prashant VermaPosted Mar 9, 2016, 9:10 PM EST
nice
Sr KarthigaPosted Feb 29, 2016, 2:48 PM EST
thank you asfend sir
Asfend YarPosted Feb 29, 2016, 9:20 AM EST
nice
Sr KarthigaPosted Feb 23, 2016, 2:39 PM EST
thank you santhakumar sir
Sr KarthigaPosted Feb 23, 2016, 2:39 PM EST
Thank you shubham sir
Santhakumar MunuswamyPosted Feb 23, 2016, 9:26 AM EST
Thanks for nice work
Shubham KumarPosted Feb 21, 2016, 7:40 PM EST
nice Article
Sr KarthigaPosted Feb 21, 2016, 6:04 PM EST
Thank you saineshwar sir
Saineshwar BageriPosted Feb 21, 2016, 6:03 PM EST
Nice one
Sr KarthigaPosted Feb 21, 2016, 2:51 PM EST
Thank you gowtham sir
Sr KarthigaPosted Feb 21, 2016, 2:51 PM EST
Thank you sibeesh sir
Gowtham KTOP 100Posted Feb 21, 2016, 6:51 AM EST
Good One
Sibeesh VenuTOP 100Posted Feb 21, 2016, 4:25 AM EST
Nice Share
Sr KarthigaPosted Feb 20, 2016, 2:37 PM EST
Thank you kumaresh sir
Kumaresh RajalingamPosted Feb 20, 2016, 1:58 PM EST
Very Nice