L293D driver board and DC motor speed control

I am struggling to understand - pwm

I have L293D driver board, see pic.
From Nano, D12 , D13 - connected to M1 IN pins. M1 OUT connected to DC motor.
Power, Groung all shared.[that is not an issue]

Now what is PWM pin, and where I should connect?

I want to control the speed of DC motor. AF_DCMotor motor1(1, MOTOR12_64KHZ); is running it forever, no matter I use RELEASE.

Can I get some help.


What is this RELEASE you speak of?
(Post code and schematic).

Please read this and then try again- the amount of detail you're supplying isn't helpful at all.

I don't understand, what information is discounted for you to miss any understanding?

Nano pins D12 and D13 connected to M1 IN, power supply { clearly shown in picture}

Is PWM required? EN1 has a jumper. [see picture]. I dont know, how pwm works , in this setup.

DC motor connected to M1 OUT pins.

Now do you want the whole circuit - like all my connections to Ultrasonic sensor, Servo motor, all breadboard connections? or a simplified part, that is simple and confined to my query?

Appreciate, if you take the details easily, and ask genuine questions [ not formalities]

Now do you want the whole circuit - like all my connections to Ultrasonic sensor, Servo motor, all breadboard connections? or a simplified part, that is simple and confined to my query?

Probably not just yet, but can you confirm that the ground of the power supply is connected to the ground of the Nano?

Is PWM required?

PWM will allow you to control the speed of the motor. Pin 12 and 13 aren't PWM pins though, so you can't use it the way you have connected it at the moment.

Are you using a library to try and control the motors? If so, can you share a link to the particular library?

Yes. Ground is shared. All are running.

Used Model 1: 1 and 2 pins are 12 and 13

  pinMode(motorPin1, OUTPUT);
    pinMode(motorPin2, OUTPUT);

   digitalWrite(motorPin1, HIGH);
   digitalWrite(motorPin2, LOW);

like wise reverse - LOW and HIGH 

    digitalWrite(motorPin1, LOW);
    digitalWrite(motorPin2, LOW);

As I am not sure , how to control the speed. I cant use this Model1.


#include <AFMotor.h>

AF_DCMotor motor1(1, MOTOR12_64KHZ); 
// Dont understand how D12 and D13 are coming into picture and what is 1..is it M1 on circuit?

//the below code is not working


Problem - DC is running on and on and on. I am unable to control

Since you haven't told me which library you're using I'm going to assume it is the one detailed here. That library is meant for a specific Adafruit shield- it won't work with what you have there. See this document for a decent explanation.

Here is a decent guide to using the L293D with PWM to control the speed of a motor.

Thanks. I have seen a lot like this.
I can get a IC, breadboard, and copy. But it is not suitable for me.

I have a motor driver board/shield, I am looking for a simple connection from Arduino Nano, to somewhere on the driver board in picture.

Should I remove the jumper? which is marked EN1

Should I remove the jumper? which is marked EN1

No. Electronics is not a guessing game, you can't just change things randomly until something works.
What you should do is spend some time researching and learning how this particular IC works. There is plenty of information on the net.

You have a motor driver board. It is not the motor driver board that the library you are trying to use will work with. So it will not work.

You need the datasheet and connection details for the motor driver board that you actually have. Post a link to the datasheet. Then we can can help you to write some code that will work with it.

It looks a fairly straightforward board but just guessing how a bit of electronics goes together tends to get expensive.


please see, if this helps. I bought from a local shop here,

Here's OP's pic

You need to have 5V on either EN pin to ENable its side's outputs. The L293 datasheet says if the EN is low, the outputs are high-Z regardless of the inputs, that is, off.

From the datasheet:

Drivers are enabled in pairs, with drivers 1 and 2 enabled by 1,2EN and drivers 3 and 4 enabled by 3,4EN. When an enable input is high, the associated drivers are enabled, and their outputs are active and in phase with their inputs. When the enable input is low, those drivers are disabled, and their outputs are off and in the high-impedance state.

The jumper is there to give you the choice of either permanently ENabling each side's output (presumably by taking 5V from somewhere on the board) or doing so under program control (in which case you would take the jumper off and use a third data pin for each motor.)

To control the speed of each motor, you need to use PWM pins (marked ~) to the inputs. For one direction, take one pin low and PWM the other. Reverse that for the other direction.

ok. great. Removed jumper. connected D5, D6 to the jumper pins. Is this correct, I am using NANO

I see some code :

pinMode(pwm,OUTPUT) ; 

analogWrite(pwm,255) ;

Added another pinMode (pwm2, OUTPUT) etc

It works!!

Thank you

Great stuff....

OP, you didn't even read the page linked to, did you? If you did it doesn't show, really.

Nano pins D12 and D13 connected to M1 IN, power supply { clearly shown in picture}

In that picture I see no Nano, no power supply, no "M1 IN" pin markings (one candidate but less than half the printing visible). No way to tell what is connected where, just a few wires that go out of the frame.

It's barely visible which way that chip is placed. The marking on it is all but completely unreadable. No connections are visible - that's all hidden on the other side of the PCB, and even that's an assumption: for all I can see there are no connections at all between the parts. Even if you had those visible I wouldn't be bothered to search data sheets and figure out the pinout of that chip, then try to follow traces, as you could just have posted your schematic and it'd be clip and clear right away.

EN1 has a jumper. [see picture].

Indeed there is a black thingy that may be a jumper with a marking EN1 next to it. But what it does... no idea, without schematic drawing and/or other documentation.