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.

  • \$\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\$ – Nick Williams Oct 13 '15 at 14:23

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

  • \$\begingroup\$ I'd add a capacitor between 0V and your 6V, size depending on your load and battery quality. \$\endgroup\$ – Wesley Lee Oct 13 '15 at 14:14
  • \$\begingroup\$ What is the diode for? \$\endgroup\$ – geckods Oct 13 '15 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 '15 at 14:36
  • \$\begingroup\$ PN2222 is a bad choice here, an N-FET would be much better. \$\endgroup\$ – Chris Stratton Mar 8 '19 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 '19 at 12:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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