L293D DC motor control, help needed

Hello,

I have just bought an Arduino Nano v3.0, and as a first project I decided to control two DC motors (by making use of pwm). I saw many examples on the internet and decided to try one, however I could not make it work. Could you please help me?

Wiring:

motor wirings:
L293D pins 3-6-11-14

two for pwm:

L293D pin1 - arduino D9
L293D pin9 - arduino D10

digital pins:
L293D pin2 - arduino D11
L293D pin7 - arduino D12
L293D pin10 - arduino D4
L293D pin15 - arduino D5

grounds:
L293D pin4-5-12-13 - arduino ground

L293D pin8 to external 9V supply (also supply's ground goes to arduino's ground)
L293D pin16 to arduino 5V

and here is the code:

#define E1 12  // Enable Pin for motor 1
#define E2 13  // Enable Pin for motor 2
 
#define I1 14  // Control pin 1 for motor 1
#define I2 15  // Control pin 2 for motor 1
#define I3 7  // Control pin 1 for motor 2
#define I4 8  // Control pin 2 for motor 2
 
void setup() {
 
    pinMode(E1, OUTPUT);
    pinMode(E2, OUTPUT);
 
    pinMode(I1, OUTPUT);
    pinMode(I2, OUTPUT);
    pinMode(I3, OUTPUT);
    pinMode(I4, OUTPUT);
}
 
void loop() {
 
    analogWrite(E1, 153);  // Run in half speed
    digitalWrite(E2, 255); // Run in full speed
 
    digitalWrite(I1, HIGH);
    digitalWrite(I2, LOW);
    digitalWrite(I3, HIGH);
    digitalWrite(I4, LOW);
 
    delay(10000);
 
    // change direction
 
    digitalWrite(E1, LOW);
    digitalWrite(E2, LOW);
 
    delay(200);
 
    digitalWrite(E1, 255);  // Run in full speed
    digitalWrite(E2, 153);  // Run in half speed
 
    digitalWrite(I1, LOW);
    digitalWrite(I2, HIGH);
    digitalWrite(I3, LOW);
    digitalWrite(I4, HIGH);
 
    delay(10000);
}

Could you help me what is wrong? I could not figure it out?

Regards,
Frank

two for pwm:
L293D pin1 - arduino D9
L293D pin9 - arduino D10

digital pins:
L293D pin2 - arduino D11
L293D pin7 - arduino D12
L293D pin10 - arduino D4
L293D pin15 - arduino D5

#define E1 12 // Enable Pin for motor 1
#define E2 13 // Enable Pin for motor 2

#define I1 14 // Control pin 1 for motor 1
#define I2 15 // Control pin 2 for motor 1
#define I3 7 // Control pin 1 for motor 2
#define I4 8 // Control pin 2 for motor 2

Why are the pins used in the sketch (12,13,14,15,7,8) different from the pins connected to the motor controller (9,10,11,12,4,5) ?!?

Thank you for your reply.

I checked the pin table, and it seemed that for example D9 is pin number 12, D10 is pin number 13, etc. That is why I used it like that. Is it wrong?

The pin numbers used in Arduino sketches are the Arduino pin numbers, not the physical pin numbers. When you do digitalWrite(10, HIGH) it comes out on the Arduino pin labeled '10'. When the instructions say to connect a wire to "Pin 10" or "D10" they mean the Arduino pin labeled "10". It doesn't matter that on one processor Pin 10 is connected to physical pin 12 and on another model to physical pin 8.

Oh thank you soo much! That solved my problem.