I am running a obstacle avoidance robot and when I connect directly from my laptop using a USB connector to the UNO board, the robot runs fine. The problem is when I directly connect the Ground and power (from a 9V battery) to the Ground and Vin pin on the motor shield, the robot goes "crazy" (while power is still on) obviously not doing the actions written from the code. Any help will be greatly appreciated!
from a 9V battery
What kind of 9V battery? Not a smoke detector battery, I hope.
the robot goes "crazy"
No clue as to what "crazy" means. Put your hands in your pockets while taking to us. Your handwaving is useless.
Read this post:
http://forum.arduino.cc/index.php?topic=235931.new;topicseen#new
If you remove the jumper and only supply pwr to the motor shield ext pwr terminals, you will see there is no voltage on the Arduino Vin, hence no +5V to either the arduino or the L293 VCC1 (pin-16).
The jumper connects the ext motor pwr terminals to the arduino Vin allowing you to run everything off that power , if and only if it is high enough voltage to supply the arduino +5V and the L298 +5V.
If the jumper is removed and you supply motor power and then supply power to the arduino ext dc power jack , you will see that the ext dc power jack supplies the arduino Vin and hence the L298 VCC1.
You have not identified which motor shield you are using OR if the jumper is present or absent.
Additionally, you have not stated whether you measure the voltage across the 9V battery when plugged into the arduino external dc power jack while the robot is having a seizure.