Servos

Hi, i just bought a Adafruit Motor/Stepper/Servo Shield for Arduino v2 Kit - v2.3. My plan was to use it to control two servo motors but i dont know how to. I own a motor shield rev 3 too and was wondering wich one I should use. I want to be able to control them using 2 potentiometer. I´ve searched for tutorials but im a beginner like I´m really new to arduino and have only done a bit of HTML programming before so just wanted to know if anyone could help me or knew any good tutorials for this!

you don't really need any shield to run servos from an Arduino. You do need an external power source as the 5V regulator on most (all?) Arduinos will not provide enough current. A 4 AA battery pack works well for servo power. Connect the servo + to battery +, servo ground (-) to battery ground (-) and to Arduino ground and the servo control pin to any Arduino digital pin. The Servo library takes care of generating the servo pulses.

As groundFungus says you don't need any shields. If you look in the IDE examples you'll see that the Knob sketch shows you exactly how to control one servo from a potentiometer.

Extending that to two of each is not exactly difficult so just have a go. If you have problems post what you've tried here and we'll help you sort it out.

Steve

i followed the instructions and powered the servo with batteries ( i had only 3AA) but it didnt move at all! do you think it is the batteries or something else?

Which servos do you have?
Do you have a digital multi meter (DMM)?
What voltage do you get out of your batteries?
3AA's likely provide 4.5v best case, less depending on their state of charge and chemistry.

Can you post a wiring diagram? Pencil, paper and a camera are good enough if you include proper detail like pin numbers.

I took a quick look at This article on that board and it says that is simply passes through pins 9 and 10 from the UNO to your servos.

In addition to the wiring diagram, can you post your code (use code tags)

Samuel72718:
i followed the instructions

Which instructions did you follow? Have you tried the Knob example sketch?

Steve

I followed the instructions for the knob experiment but used a battery to power the servo because i didnt understand how to connect both the potentiometer and the servo to the 5V port. My servo is a SG90. I dont have a DMM. I´ll post a wiring diagram tommorow since i dont have the "construction" here right now. Thanks for all the answers!

Just realized something, the potentiometer works like a changeable resistor right? and since i have different power sources for the potentiometer and the servo the potentiometer wont change anything. Is this right? and if it is how do i connect both the potentiometer and the servo to the same port?

Same port? No, no!

You can use a separate battery for the servo but you MUST connect the battery -ve to the servo AND ALSO to the Arduino GND pin.

Steve

I don't understand? Do I connect it to the servo and the board, how do I do that? What is -ve? And is there no risk that I'll fry the board?

This is a simple diagram showing servos powered by a separate power source.

Sorry, "-ve" is short for negative, i.e. in vinceherman's diagram the black wire from the battery, which is connected through the breadboard to the Arduino Gnd pin.

And provided the battery positive/red wire is only connected to the servos NOT to the Arduino there is no danger of frying anything.

Steve

Thanks a lot ill try it out today after school

Btw can I just add the potentiometer like in the knob example and use the code from there too?

Samuel72718:
Btw can I just add the potentiometer like in the knob example and use the code from there too?

Yes that will get you one potentiometer controlling one servo. Once that is going you can fairly easily work out how to add the second potentiometer and servo.

Steve

The knob tutorial is a great piece to use to learn about servos.
It is also good for helping you find physical limits of movement in the servo itself.

Can I use a 9V battery instead if I use 2 servos?

2 problems with that.

  1. Most servos, especially the small cheapies, die a quick death on 9v.
    Get a power supply appropriate for the applicaiton. 2 AA's is often a good choice.

  2. 9v PP3 or smoke detector batteries are very poor at providing more than a tiny amount of current. The current that actual motors pull (your servos each have a motor inside) quickly pulls the voltage in the 9v down and the whole system shuts down.

After reading the last post I realize that my servos are probably fried, I'll get new ones. Any recommendations for good ones that aren't too expensive?