Motor runs when USB plugged into Arduino but not when I use battery?

Hey guys, I have a motor shield with my Arduino UNO. What I am trying to do is have a motor spin as soon as the Arduino is powered and the motor will stop once my photoresistor does an analogRead greater than a certain threshold. I am able to do this fine when my USB is plugged into the Arduino. I want to eventually just upload the code to the board and use a battery to power my setup, but when I power it and press reset on the Arduino, my motor does not spin. Can anyone help me out? Thanks!

What battery? - a PP3 9v battery is useless.
Don't power the motor from the Arduino.

...R

Robin2:
What battery? - a PP3 9v battery is useless.
Don't power the motor from the Arduino.

...R

Yeah I was using a PP3 9v battery. How would I power the motor then since I want to use the motor shield.

The motorshield has its own power connector, use that.

Use a battery that has some serious power, that 9 volt version is not one of those.
You could also compose a power source out of an array of batteries (which already is the meaning of the word battery, if i'm not mistaking).
Using 6 d-cell batteries will also get you 9 volts, with a bit more power, but that still wouldn't be my choice.
First thing i would be looking into are dry acid lead accus.
Something like this (a 12 volt version here):

This is the first picture that showed up using google.

Of course this gets you lots more power, but also a lot larger size and weight.
No idea if your application can use that.

MAS3:
The motorshield has its own power connector, use that.

Use a battery that has some serious power, that 9 volt version is not one of those.
You could also compose a power source out of an array of batteries (which already is the meaning of the word battery, if i'm not mistaking).
Using 6 d-cell batteries will also get you 9 volts, with a bit more power, but that still wouldn't be my choice.
First thing i would be looking into are dry acid lead accus.
Something like this (a 12 volt version here):

This is the first picture that showed up using google.

Of course this gets you lots more power, but also a lot larger size and weight.
No idea if your application can use that.

As long as the lead acid battery is under 12V and 2A, it won't kill the motor shield right?

I'm not sure what motorshield you've got, there's several of those.
If your motorshield cannot handle 12 volts then you would need to find a solution for a correct voltage.

Never assume a battery will not output 2 Amperes.
If you let it do so, it will try to do that, even if that means a certain self destruct (see the warning about shorting it ?).
You need to reduce the current so such self destruction (of battery as well as the shield) can be avoided.

That battery on the picture must be the most sold type there is, they are in UPS'es and fire / burglar alarm systems as backup power supply.
It shows it is 12 volts and 7 Ah (Ampere / hour), meaning it should keep up for an hour at a current of 7 Amperes.
This certainly doesn't mean it can't supply 10 or 15 Amperes, but it will not do that for an hour.

MAS3:
I'm not sure what motorshield you've got, there's several of those.
If your motorshield cannot handle 12 volts then you would need to find a solution for a correct voltage.

Never assume a battery will not output 2 Amperes.
If you let it do so, it will try to do that, even if that means a certain self destruct (see the warning about shorting it ?).
You need to reduce the current so such self destruction (of battery as well as the shield) can be avoided.

That battery on the picture must be the most sold type there is, they are in UPS'es and fire / burglar alarm systems as backup power supply.
It shows it is 12 volts and 7 Ah (Ampere / hour), meaning it should keep up for an hour at a current of 7 Amperes.
This certainly doesn't mean it can't supply 10 or 15 Amperes, but it will not do that for an hour.

I was just looking at this link:

That is the motor shield that I have

fordahwin:
As long as the lead acid battery is under 12V and 2A, it won’t kill the motor shield right?

You are mixing up Amps and Amp-hrs

Battery capacity is measure in Amp-hrs so a 7Ah battery will provide 7 amps for 1 hour or 0.7 amps for 10 hours etc. It could probably provide 20Amps or 40Amps for a short time.

Lead acid batteries should be recharged fully as soon as possible after they have been used and should not be left discharged.

The current (Amps) is determined by whatever consumes the power so it does not matter if the battery is capable of supplying more Amps than you need. It is only a problem if the battery cannot supply enough Amps - as you have seen with the PP3 battery.

…R

You can use such 12 volt battery with the motorshield.
This is on its page:

The absolute limit for the Vin at the screw terminals is 18V

The nominal voltage of this battery is 12 volts, but a fresh recharged battery without load might measure something like 14 volts.
That is within limits.

I can't tell whether your motor will like to be fed 12 volts.
But do not forget that the chip uses up some 3 volts too, leaving about 9 volts for that motor.
Nevertheless do check what voltage your motor will like and what it will not like at all.

As i tried to tell before, and so did Robin2, current is not pushed into your circuit, the circuit draws it from the supply.