Arduino 5 Minute Tutorials: Lesson 5 - Servo Motors

I am using 5 servo motors to be controlled using Arduino mega, I need to power them separately, first, suggest me a suitable power supply please, and how the connections of servos to the power supply will be.

@Dr Sabreen You would connect the signal pins to the microcontroller’s digital pins, as well as the ground line (which needs to be split between the microcontroller’s ground and the battery’s ground). The easiest way to make connections between a servo (or sensors) and an Arduino is to use a shield which has 3-pin connectors for signal, voltage and ground.

If possible to use your teaching for Pic programming?

@Andres Unfortunately this series would not apply to PIC programming.

i have problem and i want a help i making a robot arm and when i testing one servo it make the same rotate even if i chane the angle in code it does not change please any help Coleman Benson

@alaa mabruk Hard to diagnose without knowing a lot more about the setup. Please create a new topic on the RobotShop Forum and provide as many details / images as possible.

i have problem with making new topic can i contact you another way … thank you @Coleman Benson

@alaa mabruk You can send an e-mail to [email protected]

@Coleman Benson Sorry i can not using this way can i call you using yahoo mail if possible and thanks in advance

@alaa mabruk Unfortunately I cannot provide a personal e-mail.

I run a program with a firgelli microlinear actuator and a servo library on arduino. I use angles to make the linear actuator move farther, or retract more. It says above that a standard servo will go from 0 to 180 degrees, but in my code i have the actuator running up to 400 degrees. When I set it to 180, it moves a tiny distance. Is there a reason for this? Or is there a better way to write the code where i don’t use angles for a linear actuator? Thanks.

@alejandra pacheco If we assume you have an L12 with PLC/RC input. Note that the minimum signal is 1.0ms, 1.5ms is half extension and 2.0ms is full extension. For a normal servo, this would correspond to 45, 90 and 135 degrees.

Hi Coleman. Many thanks for a great starters tutorial. I am a senior newcomer to this Arduino business, and am enjoying it immensely so far. Now then. If I may ask… I see in the program you allow 15ms for the servo to move one ‘click’ before the next instruction is given. I was wondering why this number exactly? Is this how long it takes an average servo to move up or down one value? Many thanks again. Nigel

@NigelB You mean the delay of ~20ms? The servo’s program is waiting for a timed “high” followed by a longer delay before this signal is re-sent. It’s just the way RC servos operate.

I have a question, I’m designing a prototype of an instrument and I am using a servo to spin a ratchet, the power consumption spikes up to 200mA for less than a second at every cycle.
Now, I am using a RedBoard to control the whole thing and it should be more or less the same as an Arduino Uno. I am using a Futaba S3003 servo and I am powering it directly from the board. I have read everywhere that I shouldn’t do that and that the board wouldn’t be able to power it, but when I tried it just for a laugh, it did work both from the 5V and the 3V pin. I have a reasonable torque out of the servo (likely not the 100% but it still gets the job done) and I’m thinking of keeping this solution to minimise wiring. I have measured the servo current draw at 9.5mA in idle and something around 200mA at the peak torque (in my application).
the question is: how come the servo is able to draw that much from the pin? isn’t the pin regulated?
also, the servo would cycle 12 times per day (2 cycles at 2h intervals), I had the servo operating non stop (with shorter cycles) for a few hours and I didn’t register any faults or overheating anywhere, so I would assume that the system would work in normal conditions. where am I wrong?

@Coleman Sir, my project is of a humanoid arm, more like demonstrating human-like finger movements. I’m using 5 servo motors for each finger. My question is, Is there any problem if I give common Vcc and common ground to the five servo motors, all of which I’m controlling through arduino?
Or would I need to separately give them supply?

@Ashish Mishra You should not use the Arduino’s IO pins to power these servos - you need to power them directly from a battery, but ensure they are all connected to the Arduino’s GND pin as well.

@Max On an Arduino Uno, the 5V output comes from the regulator: “This pin outputs a regulated 5V from the regulator on the board. The board can be supplied with power either from the DC power jack (7 - 12V), the USB connector (5V), or the VIN pin of the board (7-12V). Supplying voltage via the 5V or 3.3V pins bypasses the regulator, and can damage your board. We don’t advise it.” A digital IO pin however can only provide around 20mA of current. So long as you don’t have many other parts which draw current, and your power supply can provide the necessary current, you should be fine. A few cycles should not cause the servo to overheat.

i want to use servo motor mg996r. my project is when a sensor detect a water, the visor of helmet automatic will down (0 degree) and it stay that position until push on a button,the visor will up (90 degree), i also want to control servo in manual when push on button, the visor will down, then when i push off button the visor will up. i want in two condition manual and automatic. so how i create the coding to control that servo motor. can u help me?

@Atiey.M Unfortunately we are not in a position to teach you how to create custom code. We suggest a book which teaches you about programming in Arduino: https://www.robotshop.com/en/books.html