Attaching a servo locks second DC motor controlled via L293D driver

Hello.
I have an Arduino Uno board and two DC motors contolled via a L293D driver. This simple circuit runs well and both engines work.
The problem is when I attach a 9g servo. Then the second DC motor doesn’t work (right side of the L293D), but the first engine runs Ok (left side of the L293D.
The 2 DC motors have an independent power supply using a 9V battery. The servo uses the 5V output from the Arduino board.
The 2 DC motors and the servo use different digital PWM pins. They are here:

First DC engine:
enable pin = 4;
driver input pin 1 = 6;
driver input pin 2 = 5;

Second DC engine:
enable pin = 8;
driver input pin 1 = 9;
driver input pin 2 = 10;

9g Servo attached pin = 3

Can you help me?

Regards.

With no code I can't tell how you're trying to drive the DC motors.

But it is well documented that using the Servo library disables PWM on pins 9 and 10. Try moving the second motor to different pins.

Steve

Usually you use a PWM pin connected to the enable pin of the 293 to control speed and connect the 293 pin1 and pin2 to digital (non PWM) pins to control the motor direction and braking.

Thanks a lot for your replies.

I don’t know if the servo library disables PWM on pins 9 and 10. If you tell that, I will take note, of course. Thanks a lot for the advice. My problem is I need all PWM pins because I put other stuffs like an IR receiver and an ultrasonic sensor, which also use other PWM pins.

But I found a better solution using all these pins…

I thought the problem could be that probably the servo was consuming too many energy, and the Arduino was providing not enough with his 5v to supply the L293D, the servo and the other stuffs. In that case, the L293D could be driving only one of the two engines. Remember the 2 engines have their independent 9v battery power supply.

With this in mind, I try to put a L7805CV power regulator in scene: The input pin of the regulator connected to the +9v battery, and the 5v output pin directly to the pin 16 of the L293D, and… Oh, magic! It works exactly as I want.

With that, the L293D don’t uses the Arduino 5v power supply, and all works using pins 9 and 10 and all other pins.

Thanks a lot, again!

Regards.