Did I connect the 9V battery correctly? Robot hiccups/sputters on battery power.

This is my first project in arduino, I built an "insect robot" from the 'O'Reilly Make Bots & Gadgets book'. It's basically a ping ultrasonic sensor connected to an uno board, with two servos and wirehangers as feet. Here's a picture:

Anyway, here is my problem.. and this could just be some beginner's mistake. It works perfect when it's connected via USB power. However, on battery power it hiccups/sputters (and the led 13 light comes on, where it doesn't come on at all on USB power) and it keeps stopping. I assume a short or something not right...

This is how I connected the battery:

I attached a 9V battery to an on/off switch. (I cut the red power cable from the battery adapter plug in half, and soldered the switch in between the cut red wires. The other end of the red wire is plugged into the "Vin" pin on the Uno board. The black ground wire goes directly from the battery to ground on the arduino board. Is this correct?

When I have it on battery power it is NOT connected via USB cable at all, in case you were going ask :wink:

I'm not seeing any electrical shorts, and I put a multimeter on the two prongs of the on/off switch and am getting a stable 8.5 volts.

Any help/advice would be much appreciated.

Thanks
Nathalie

It's most likely that the battery can't supply enough current. 9v batteries are pretty crappy for anything beyond a few blinking lights.

That would explain the pin 13 light being on, the arduino could be browning out and resetting as the motors draw too much current.

When it does run, and the servos just jitter, it could be that you need power supply decoupling, which could be helped by placing a capacitor across the battery. Grumpymike has a good explanation of this. But this is problem is a bit of a moot point if the battery can't even supply enough current.

As for this,

natv:
I put a multimeter on the two prongs of the on/off switch and am getting a stable 8.5 volts.

I would hope you misspoke, because wouldn't a voltage across the two prongs of the switch mean a short between the VIN and GND on the arduino? :astonished: (or am I just derping?)

Thanks for the reply. What kind of battery would you recommend I try, and if it's > 9V I assume I need to use something between the battery(s) and the Uno board?

Regarding the multimeter, now you really have me wondering if I've connected the battery and switch wrong (?). The ground wire is going directly from the negative on the 9V battery to the Ground pin on the board (it doesn't connect to the switch at all)

The on/off switch is a sliding switch. I cut the red wire that goes between the battery and Vin pin and soldered each part of the cut wire to the prongs.

Here's a picture of the setup. Was I supposed to put a resistor or something between the battery and the Vin pin? (since the battery is 9V and the board is 5V now I'm wondering if that's my problem and I'm overpowering the board?)

Thanks again

You have that hooked up right.
It's like sdguy said, the 9V isn't a "deep cycle" battery, it's not good for much current.
Look for a 6x"AA" holder with a set of battery-snap terminals.
Standard servos have current surges with every movement (once they get going, continuous servos have a more steady-state situation).

You could run the Arduino and Ping from the present 9V battery (but the Ping is a current hog, too) and run the servo from its own 6V (find a 4x"AAA" holder).

Batteries can be heavy and I'm not sure how much your little walker-bot can bear.

thanks for the advice.

With 2 sources of power (say, the 9v for the arduino and ping sensor, and an extra battery back of some kind for the servos...), do I connect ALL the negatives (from everything - ping,servos,9v AND negative of extra battery back) to the same ground pin?

All the grounds need to be connected - the Uno has several ground pins though which are themselves connected, so you can use several of them if it's more convenient.