Hi there! I am new to Arduino, I've been working on a project lately that requires me to control a servo motor. I initially wanted to use the Motor Shield but my teacher gave me a L293D Motor Driver instead. Thing is, its not just an IC (in whose case loads of tutorials are available), it is a complete module( Image attached).
The module has 6 pins namely EN1, EN2, IN1, IN2, IN3, IN4. I am not really sure which pin goes where and how on earth can I control my motor through it. I have to control the motor based on the feedback of three HC-SR 04 sensors which are sensing obstacles. Anyways, can somebody help me out as to how to get this module up and running? I am using an Arduino UNO.
Thanks...
jremington:
Connect the inputs to port pins, and set the pins HIGH or LOW as desired. Also connect the grounds, and 5V power to Vcc on the module.
It may seem rather amazing, but googling "arduino l293d robot" actually turns up relevant web pages!
Thanks I would definately give it a shot... So if I am right, the IN pins are input formotors and EN pins are for power from the Arduino?
But why does every motor has two inputs? To rotate it in both directions or what?
But why does every motor has two inputs? To rotate it in both directions or what?
A quick look at the L293D data sheet (I'm surprised that you haven't done this yet!) shows that there are four motor functions, two directions and two braking for each motor, controlled by two inputs. Then, there are the EN (enable) inputs, often used for PWM control.
jremington:
A quick look at the L293D data sheet (I'm surprised that you haven't done this yet!) shows that there are four motor functions, two directions and two braking for each motor, controlled by two inputs. Then, there are the EN (enable) inputs, often used for PWM control.
My bad, I had downloaded the datasheet to my phone and forgot about it, sorry for that.
PWM control sounds like speed control isn't it? Can you suggest some tutorial or anything regarding the pins on the Arduino UNO? I tried googling but it didn't satisfy me, I guess I gotta learn the pins first.
JimboZA: Servo tutorial here; just ignore the part where they power (as opposed to control) the servo from Arduino; use a separate power source.
Yikes! The tutorial says that servos have 3 wires, I googled and found that servos do have 3 wires, mine only has 2 ( red and black), there's a third empty hole from where the wires are emerging. Does that make my servo useless?
YaddyVirus:
there's a third empty hole from where the wires are emerging. Does that make my servo useless?
I'd say so, unless it's some kind of customisation I'm not aware of. The third wire is the control, through which the servo library sends the positioning pulses.
Perhaps it got ripped off?- if you can open the casing you might see where it was attached and solder a replacement.
JimboZA:
Perhaps it got ripped off?- if you can open the casing you might see where it was attached and solder a replacement.
I tried opening up the servo, all I found was a regular looking motor with quite a few gears, the red and black wires were coming out of the motor terminals but I couldn't find where the third wire goes...
JimboZA:
Well there's usually some control electronics in there, which is where the 3rd wire would go.
So maybe it's just a normal motor in a servo casing?
I don't know, my teacher gave me that servo, said he took it from a robot, so maybe it was modified to work in that specific robot, so I'm gonna have to find another servo.
Until then, lets use the motors I have lying around.
So after quite a lot of fiddling I can't get the module to work. I'm really confused about the EN1 pin. I am using only one motor (on OUT 1&2), and connected the IN 1 and IN 2 pins to 12&13 on my arduino. But where does the EN1 pin go?