unstable analog readings with l293d v1 shield when not connected to pc.

Dear all,

we are making a "robot" that can drive around with instructions based on a raspberry pi. We want to do this by using a l293d v1 motor shield. We have succesfully made an obstacle avoiding and a line following robot as of yet. Now we want to connect a raspberry pi to it that we will control via a server on the pi. To do this we want to read the pi with 4 pins. We have made our prototype and we have tested it while on the pc powersupply(the arduino i mean) and this works great. Now, as we are making it portable, we connected it to a 9v battery and suddenly it doesnt work anymore. The motor goes on and off randomly, but it seems to be worse when we touch the pins. This lead us to believe the battery was the fault. We connected the arduino to a wall charger, three powerbanks and another 9v battery, but it all doesnt work. We also disconnected the motorshield to just control a led using the 9v battery as a powersupply and this did work. Does anybody have an idea as to how we can possibly solve this problem because we haven't got a clue.
many thanks in advance.