B8: Servo Motor Connection diagram for all servo codes

AR-B8: Servo Motor Basic Code

This entry is part 8 of 13 in the series Arduino Basic Circuits

In this code the servo motor is controlled in required angle. We can change the value of the angle in the code either positive or negative angle.

Required Material

Arduino UNO Board – 1, data cable – 1, Servo Motor – 1, Jumper wires – 3.

Working

Servo motor is used in humanoid robots and automatic machines in industries.  Servo motor rotates only from 0° to 180° i.e. half circle. When you upload the code in Arduino, the motor start rotating. First it resets back to 0° from any previous position. Then after 1 second it turns in 90° and then after 1 second again it rotates in 90° and finally it comes back to 0°.

Precautions

  1. DO NOT ROTATE THE SHAFT OF THE SERVO MOTOR WITH YOUR HANDS. IT WILL DAMAGE THE SERVO MOTOR.
  2. Connect the orange wire of servo motor to any Pulse Width Modulation pin i.e. PWM pin like pin-3, pin-5, pin-6, pin-9, pin-10 or pin-11. These pins are marked as (~) on the Arduino board.

image 19 Vidyasagar Academy Akola
Connect servo motor wires as shown above. WRONG CONNECTIONS WILL DISTROY THE SERVO MOTOR.

Procedure

  1. After uploading the code, connect the 3 wires of servo motor as shown in the diagram on next page.
  2. Then connect Arduino to USB port through data cable.
  3. The motor will start rotating as per the angles set in the program.

The Code

Servo motor is very useful in robotics to get the machine level action of a robotic arm or automated system. Just copy the following code and upload in Arduino UNO to run the project successfully.

Signup or Login to view remaining content. It's Free!
Share on your network!
Dattaraj Vidyasagar
Dattaraj Vidyasagar

Author on this website. He is veteran of Core Electronics since last 35+ years. ATL Mentor of Change, Niti Ayog, Govt. of India, Google Certified Educator, International Robotics Trainer and author of 17 books on electronics, robotics, programming languages and web designing... ➤➤

Leave a Reply

Your email address will not be published. Required fields are marked *