1
\$\begingroup\$

I'm new to both StackExchange and electronics in general.

I want to be able to turn on and off a DC motor using my Raspberry Pi. I have a breadboard, a 6V DC motor, an NPN Transistor (ST 2N2222), a battery holder that holds 4 AA batteries (and consequently has a P.D. of about 6V), a raspberry pi, and wires. Also, can I use Pulse Width Modulation in this setup, and if so, how? If possible, please include circuit diagrams.

I know that this will be much easier to do using an IC Motor Controller (like L293D), but I want to know if it is possible using a transistor instead.

Thanks in advance.

\$\endgroup\$
1
  • \$\begingroup\$ You can use the transistor if the current that can pass through it is enough to turn the motor. So basically, only if it's a little toy motor. \$\endgroup\$ Oct 13, 2015 at 14:23

1 Answer 1

3
\$\begingroup\$

Googled "raspberry pi transistor" and found many results that would suit your need.

Make sure the transistor can handle the motors current.

PWM is possible with this configuration.

enter image description herehttp://justinzondagh.com/wp-content/uploads/2013/06/2013-06-03-Motor-Switch-NPN-Transistor2-624x365.png

\$\endgroup\$
5
  • \$\begingroup\$ I'd add a capacitor between 0V and your 6V, size depending on your load and battery quality. \$\endgroup\$
    – Wesley Lee
    Oct 13, 2015 at 14:14
  • \$\begingroup\$ What is the diode for? \$\endgroup\$
    – geckods
    Oct 13, 2015 at 14:16
  • \$\begingroup\$ @geckods to protect the transistor. It's called a flyback diode or a catch diode, or a snubber diode .. en.wikipedia.org/wiki/Flyback_diode \$\endgroup\$
    – efox29
    Oct 13, 2015 at 14:36
  • \$\begingroup\$ PN2222 is a bad choice here, an N-FET would be much better. \$\endgroup\$ Mar 8, 2019 at 3:38
  • \$\begingroup\$ @ChrisStratton - I agree, this was on my early days on EE.SE I wasn't super familiar with the embedded circuit editor so I just used an image I found on the web. \$\endgroup\$
    – Wesley Lee
    Mar 8, 2019 at 12:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.