L293D motor driver circuit problem

Hi! I'm trying to control two small DC motors. They are similar to these motors (http://www.pololu.com/catalog/product/187) but are of local make. I've a L293D H Bridge circuit to control it. I've also a voltage regulator circuit that uses a LM7805 voltage regulator for regulated 5V source. Power supply is from a 12V 2A wall adapter. The Vs pin(pin 8) of the L293D is connected to positive of the unregulated power supply and rest of the L293D circuit is usual. I want to achieve motor direction control using Arduino. I'd read at some tutorials that it is a good idea to use separate power sources for Arduino board and motors. So I power the Arduino from a separate 9V battery.

I'm facing a weird problem. When I'm supplying 5V and Gnd to the input pins of the L293D directly from the voltage regulator circuit, the motor is rotating normally and reversing direction on reversing the input. But in this state, the moment I connect the ground of Arduino(powered on) to L293D circuit, the motor stops rotating. Any ideas on how to resolve this issue? I'd used the same circuit and setup with common grounding before, on a different pair of bigger DC motors than these ones and hadn't faced such a problem.

I'd not used independent power sources the last time though while controlling the bigger dc motors..

Please help! :(

Can you post a schematic of the circuit?

Also you need to post your code. Have you defined the pins to be outputs?

Actually I was making a silly error. The batteries I was using didn’t have enough juice to power the motors. I replaced them with higher mAh batteries and now they work fine. Thanks!