Intro: How to Use Less Arduino Pins With the L293d
Those of us who use the arduino to control an L293d to drive motors always use 6 pins from the arduino to control the L293D chip. Well I was using this motor-shield from Sparkfun.It uses an l298 chip, but they used only four pins from the arduino to control it. So i tried the same with the l293d and it worked.
Step 1: The Ardumoto From Sparkfun
As can be seen near the L298d are two smaller chips. These are inverters . The schematic is below
Step 2: The Schematic Diagram of the Ardumoto Shield
Step 3: The Standard L293D Schematic
As can be seen from the diagram there are six wires used from the arduino. If you want to add a couple more L293ds to your project you won't have enough pins for sensors or other things. Yes you can use the analog pins as digital by labeling them as such in your sketch. Why not simply use a couple of NPN transistors and four resistors and you save two pins which can be used for functions. The following is what I came up with.
2 NPN transistors - i used 2N3904's any small NPN will do
2 1Kohm 1/4W resistors
2 10Kohm 1/4W resistors
and jumper wires
I initially used a a 74HC04 inverter chip, which has 6 inverters on it but decided to use the transistors because the chip would be overkill.
As can be seen from the schematic diagram.IN1 goes to IN1 of the L293 and to R1. The signal from the collector is the opposite of IN1 which is fed . IN2. The same happens with Q2.
The code for this was the modified code used by Rui Santos to show the control of motors with Bluetooth. I tried his design and it worked with Bluetooth. This instructable is not about Bluetooth control but about using less pins.
attached is the sketch for this.
The L293 is the lower power version of the L298. I used the same idea as Sparkfun when I built this controller for four motors