Update: I'm currently changing a few things with the project. I took some of you advice. I've changed from a stepper motor to a RC servo (controlled through PWM) and if I run into any problems and can't figure them out I'll ask.
Thanks for the help!
I'm working on a project with a friend and its our first time using an Arduino. We're using an Arduino to take data from a sensor (accelerometer) and then turn on the motor (6V, DC).
I've been doing some digging and it seems like the power out from the Arduino might not be enough for the motor and sensor at the same time. Maybe a delay of sorts could work (would this be possible?).
I'm contemplating using a motor shield. Will I still be able to control the accelerometer along with the motor?
I'm trying to use a single external source of power (max: 6 AA batteries; I'm trying to limit the amount of batteries since we're trying to keep it portable) so is there a way to use one source since the Arduino and motor shield need two different power supplies (from my understanding).
Best Answer
Issue 1: Driving a motor directly from an Arduino
Driving a motor directly off the Arduino pins is not advisable for multiple reasons:
While each Arduino pin for ATmega-based Arduinos is rated for 40 mA, I personally prefer to keep any sustained loading to under 30 mA, your risk appetite may differ. Without seeing the datasheet of the motor in question, it is impossible to surmise how much current the motor requires
Back EMF is basically reverse voltage generated by the motor coils (or any inductive load at turn-off), transients (spikes) that can momentarily far exceed the acceptable voltage range the microcontroller pins can tolerate.
Back EMF remains a risk, albeit abated, even if a fast diode is connected in reverse bias across the motor's leads, a strongly recommended practice.
If you are comfortable with basic electronics, this can also be achieved by directly wiring up a suitable motor driver IC and flyback diodes. (Edit: This is excellently described in the answer by Manishearth)
The motor driver, whether a shield or an IC, should be powered independently of the Arduino, but with the two power source ground lines connected together. See further down.
Issue 2: Controlling accelerometer and motor shield simultaneously
For convenience, look for a motor shield with stackable headers, i.e. with the Arduino header pins replicated on the motor shield for attaching additional hardware, in your case the accelerometer. Not all shields provide stackable headers. Thus complicates using the pins not utilized by the shield, needing wires to be soldered to the relevant header pads on the PCB, or some such arrangement.
On the off chance that the motor shield you select uses up all GPIO pins, as can be the case with shields for driving multiple motors, you may have a problem. Since only 1 motor is to be driven, avoid multi-motor shields which do not leave enough unused GPIO pins.
Issue 3: Power distribution between Arduino and motor shield