Simple way to control 12V DC Motor using Raspberry Pi’s GPIO port and NPN transistor




I needed to control a DC motor from my Raspberry Pi’s GPIO port as part of my time-lapse dolly project. I had to be able to turn the motor on for approximately 150ms which would in turn move the dolly along by 3mm.

Parts

Simple way to control 12V DC Motor using Raspberry Pi’s GPIO port and NPN transistor.jpg

Circuit Diagram

  • The NPN transistor acts as a switch. It allows current to flow from the collector to emitter when a potential difference is applied the across base and emitter. See Wikipedia for more info on how they work.
  • The 270Ω resistor (R1) protects the Raspberry Pi’s GPIO port by ensuring that not too much current flows from the GPIO port.
  • The 10kΩ resistor (R2) helps pull the base back down in case there is some leakage. You may not require this one but add it if you see the motor turning very slowly.
  • The diode ensures that reverse current generated by the collapsing of the DC motor’s field when the motor is turned off does not damage the NPN transistor and GPIO port. Diodes only allow current to flow in one direction.
  • The 12VDC motor in this circuit draws up to a maximum of 50mA under full load. To check the max load of your motor connect an ammeter in series with the motor to a battery and hold the shaft and watch where the current maxes out.

 

For more detail: Simple way to control 12V DC Motor using Raspberry Pi’s GPIO port and NPN transistor


© 2015 Powered By Engineering Projects Team, Raspberry Pi Projects

Scroll to top