Problem with 2 servos

I´m using the Megaservo library. I use pin 9 and pin 10 for the servos.

The program just moves the servos from 0º to 180º. If I connect just one servo it works perfectly, but when I connect both of them the Arduino board seems to reboot every 2 seconds.

I´ve tried powering with the usb cable and with 2 9v battery in parallel, but nothing worked.

I suppose the problem is that is not enough current for 2 servos. I wanted to do a something like a line following robot, so I can not use a wall adapter.

What is the problem? How do you power 2 servos?

Thank you

Separate power supply. Always.

Each servo with its own 9v battery (for example)?

Ok, I'll try and I'll post the result.

Thank you.

Caution, most hobby servos will not tolerate 9vdc power directly, that's too much voltage. Your problem is undoubtedly insufficient current capacity to run two servos at the same time. The USB power is also marginal for two servos. Even the Arduino's external power is limited by the on board 5vdc regulator in it's ability to supply the amount of current that two servos might draw, depending on load and specific servo specifications. You need to supply DC voltage that has sufficient current capacity to drive the number of servos you wish to operate.

Lefty

Do not connect 9V to your servo, as it will most likely let the magic smoke out.

Hobby level servos do work with 5-6V, usually 4 NiCad batteries.

If you have to use 9V battery, get yourself a 7805 Regulator to cut it down to 5V. A small slip on heatsink will give you 1A through it, which is more than a 9V will give anyways.