stepper motor driver notes

Active today
Viewed 20 times

I am trying to control some 5v stepper motor driver inputs using GPIO. I found this helpful tutorial and was able to get it working (scroll to the last post where he’s got it rigged up to a breadboard with transistors, etc, with pictures):


However– I don’t understand WHY it works. Or at least, I think I might, but my recollection of NPN transistors is that the collector is always set to ground and the switch helps complete the circuit. Like, using an LED on the collector with a 5v supply and using the 3.3v supply on the base, it allow sthe LED to turn on by giving access to ground when turned ‘on’ by the GPIO.

However, when you connect 5v from the RPi to the + leads on the motor controller, and then use the transistor as a switch to the negative side, I’m having trouble figuring out how that is the same thing– is the circuit inside the stepper motor basically like an LED in that all we are doing is supplying access to ground to get them to turn on?

edit: to clarify

Is this correct: versus using the 3.3v GPIO pins to control the + inputs of the stepper motor directly and connecting the – inputs to ground, since it has insufficient voltage, instead we are using the constant 5v source from the pi and controlling the switch on the negative side, supplying access to ground to complete the circuit by using GPIO pins as a switch to a transistor?

 New contributor
  • 1
    This appears to be a general electronics question. The Pi is irrelevant. – joan 6 hours ago
  • Perhaps you’re right, but the pi is not irrelevant– from an applied perspective, this is one of the only ways to control a 5v input using the pi’s 3.3v GPIO pins without an external power source or relay. People searching for this exact problem will find this and hopefully, it will help them. I am just trying to understand if I have the science right so I don’t blow up my Pi. Thanks. – Hodor 6 hours ago
  • Not only is this question off topic; the suggested circuit connects the GPIO directly to a transistor base, effectively shorting the GPIO. The alternative (a PNP transistor) is even worse – it connects the 5V to a GPIO and would short the 5V supply! Both risk damage to the Pi. See elinux.org/RPi_GPIO_Interface_Circuits#Using_an_NPN_transistor for a proper circuit. – Milliways 1 hour ago
  • @Hodor, your using Rpi GPIO pins to drive 5V stepper motor driver is OK but need to be very careful of not to carelessly connect 5V power to Rpi GPIO pins. I see your are using NPN BJT such as 2N2222 to prevent this over voltage. But EE guys usually use opto-isolation modules to reduce noise step up and shift up logical levels. Optoisolation is very important, because back EMF and EMI always jumps back to Rpi, possibly freeze it or fry it. Perhaps I can search my junk box for a old stepper motor driver and share my stepper motor toys with you. – tlfong01 1 hour ago    
  • @Hodor, your use of the verb “amplify” to describe your NPN BJT operation is a bit misleading. NPN BJT such as 2N2222 can either do “amplification” or “switching”. In your particular case, it is sort of switching, but mainly “level shifting”. You need to go to electronics tutorials, as recommended by >Fred below, to get a solid foundation on NPN BJT for amplification and switching, use of pull up resistors and so on. Happy learning and cheers. – tlfong01 1 hour ago   

2 Answers


is the circuit inside the stepper motor basically like an LED in that all we are doing is supplying access to ground to get them to turn on?

Yes. In an NPN transistor current flows from the collector, through the base into the emitter, i.e. it acts as a sink. In your circuit then, +5V from the Pi flows through the stepper motor controller, through the transistor, through to ground. The current only flows when the base is activated.

A simple explanation of NPN transistorsA bit more detailed explanation of NPN transistors.

  • Your references are very good. I always refer newbies and professionals to “Electronics Tutorials”. The good thing about “Electronics Tutorials” is that they are very comprehensive, and from basic to advanced, so newbies can start from beginning. or jump around. I myself from time to time visited their site to update/upgrade EE knowledge/skills. I also often go there to clarify confusing things. For example, I never understand why use “phasor” to represent AC signals, and why use the mysterious operator “j”, and constant “e”, which are used in very basic capacitor circuits. – tlfong01 1 hour ago   



How to connect Rpi 3V3 GPIO pins to 5V Stepping motor controller?


Answer not yet ready. See Learning Notes below to see how a newbie can research and arrive at an answer

/ to continue, …

Learning Notes

Let let use the picture in the forum discussion referred by the OP here.

stepping motor

/ to continue, …


(1) SMD Step Motor Ddriver

(2) SMD Step Motor Driver Catalogue

/ to continue, …


Appendix A – Step motor driver Smart Motor Driver Description


The step motor drivers SMD Series by Smart Motor Devices offer a compact and easy solution for controlling stepper motors.


Power supply 12-48 Vdc and 24-120 Vdc

Adjustable current from 0.2 to 9A

Clock and direction input

Full step, 1/2, 1/4, 1/16 resolution

.End of answer and learning notes, comments follow, …

  • I found the link to the step motor driver referred in the OP’s forum discussion is 4+ years old and is broken. So I googled a driver from the same manufacturer, but I have not checked it is the same driver. Anyway, I think any step driver with similar/smaller spec (12V, 2A, Clock and Direction, Full 1/2, 1/4, 1/16 should be OK for general discussion here. Counter suggestions welcome. – tlfong01 just now   Edit   

Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: