Using transistors to minimize the number of Arduino pins used for this stepper motor driver

arduinomotorstepper motor

Alright, I know very little about what I am currently asking about, but here is the gist of it:

I want to build a cnc machine out of some old floppy drives. I purchased a couple L293D dual H-bridge ICs to drive the stepper motors, and I want to interface with grbl. The problem I seem to be having in designing a proper circuit for this is the circuits for driving stepper motors with the L293D all involve two inputs, one for each direction, and grbl seems to only use one Arduino pin for direction for each axis.

So what I've thought up is using a pnp and an npn transistor to act as a kind of two way switch, when I apply voltage one goes on, other goes off, and vice versa, so that basically 1's and 0's are controlling which way the motor will spin, and the "step pulse" will provide the actual motor power to move it in that direction.

My question is: will this work, or is what I said complete non-sense? I only understand pnp and npn transistors to be something like a "usually on" or "usually off" logic switch, basically, so that's where I've come up with that… Kinda like how an H-bridge works in the first place.

Thanks for taking the time, the diagrams I'm looking at are:

grbl to Arduino pins:
http://www.electrodragon.com/w/images/e/e7/Grbl_Pin_Layout.png

L293D driving a stepper motor:
http://arduino.cc/en/uploads/Reference/bipolar_stepper_two_pins2.png

Best Answer

I think what you're really after is an IO expander: http://www.digikey.com/product-detail/en/SX1505I087TRT/SX1505I087CT-ND/2272323

It's a relatively simple digital device. The Arduino would communicate with the IO expander over some standard communication protocol (typically I2C or SPI), and the IO expander wiggles pins on behalf of the controller.

Instead of using 12 pins on the Arduino to directly control the H bridges, the Arduino uses 2 pins (in the case of I2C) to communicate with the IO expander, and the IO expander directly controls the pins. The Arduino would say "Okay Mr. IO Expander. Turn on your pin2 and switch off your pin8", and the IO expander would set those pins accordingly.