user1506: I want to power a small motor with a 9V battery and control it with PWM using an Arduino Leonardo. I know I can power the motor separately, but this introduces the problem of needing a battery to power the motor (9V battery) and another power source to power the Arduino (another 9V battery?)
Would it be safe to simply power the Arduino with a 9V battery and use the Vin pin on the board (which is unregulated and outputs directly the power source powering the Arduino) to drive the motor? That way, I power everything from the 9V battery, and use a transistor to drive the motor.
Thanks a lot!
Steve.

user1372: If you use a transistor circuit as shown below, back EMF would not cause any trouble.


1506: <p>I want to power a small motor with a 9V battery and control it with PWM using an Arduino Leonardo. I know I can power the motor separately, but this introduces the problem of needing a battery to power the motor (9V battery) and another power source to power the Arduino (another 9V battery?)</p>

<p><strong>Would it be safe</strong> to simply power the Arduino with a 9V battery and use the Vin pin on the board (which is unregulated and outputs directly the power source powering the Arduino) to drive the motor? That way, I power everything from the 9V battery, and use a transistor to drive the motor.</p>

<p>Thanks a lot!</p>

<p>Steve.</p>
 1372: <p>If you use a transistor circuit as shown below, back EMF would not cause any trouble.
<img src="https://i.stack.imgur.com/87qTl.png" alt="enter image description here"></p>
