Arduino project doesn't work without the USB cable connected

Before anything, I have searched up on the Internet and found that you need to connect Tx and Rx but that made no difference at all :frowning:

I am making a obstacle avoiding robot without a servo but using 2 DC motors instead.

I have wired everything correctly as when I open the serial monitor, the correct sentences are displayed.

When I plug in the UNO to the board and upload the program, both motors drive forward but when I put my hand in front of it, it makes one motor go forward and one motor go backward.

However, when I disconnect and plug in my 9v battery, it waits a while and then starts spinning although there is no obstacle in front of it.

I am using a Arduino UNO and a Adafruit motor shield v1, the sensor that I am using is the HC SRO4

The motors are connected through motor 1 and motor 2 ports

The HC SR04 trigger and echo pins are connected through the servo ports on the shield which are connected at digital pins 9 and 10

This whole setup is working and accurate as the motors turn when there is a obstacle in between 1cm and 26cm

HERE IS THE CODE THAT I HAVE USED:

Before anything, I have searched up on the Internet and found that you need to connect Tx and Rx but that made no difference at all :( 

I am making a obstacle avoiding robot without a servo but using 2 DC motors instead.

I have wired everything correctly as when I open the serial monitor, the correct sentences are displayed.

When I plug in the UNO to the board and upload the program, both motors drive forward but when I put my hand in front of it, it makes one motor go forward and one motor go backward.

However, when I disconnect and plug in my 9v battery, it waits a while and then starts spinning although there is no obstacle in front of it.

I am using a Arduino UNO and a Adafruit motor shield v1, the sensor that I am using is the HC SRO4

The motors are connected through motor 1 and motor 2 ports

The HC SR04 trigger and echo pins are connected through the servo ports on the shield which are connected at digital pins 9 and 10

This whole setup is working and accurate as the motors turn when there is a obstacle in between 1cm and 26cm

HERE IS THE CODE THAT I HAVE USED:


[code]Before anything, I have searched up on the Internet and found that you need to connect Tx and Rx but that made no difference at all :( 

I am making a obstacle avoiding robot without a servo but using 2 DC motors instead.

I have wired everything correctly as when I open the serial monitor, the correct sentences are displayed.

When I plug in the UNO to the board and upload the program, both motors drive forward but when I put my hand in front of it, it makes one motor go forward and one motor go backward.

However, when I disconnect and plug in my 9v battery, it waits a while and then starts spinning although there is no obstacle in front of it.

I am using a Arduino UNO and a Adafruit motor shield v1, the sensor that I am using is the HC SRO4

The motors are connected through motor 1 and motor 2 ports

The HC SR04 trigger and echo pins are connected through the servo ports on the shield which are connected at digital pins 9 and 10

This whole setup is working and accurate as the motors turn when there is a obstacle in between 1cm and 26cm

ps :I have a 6v battery holder with AA batteries connected to the motor shield aswell as a 9v battery 

HERE IS THE CODE THAT I HAVE USED:

I ALSO ADD A ATACHMENT

obstacle_avoiding_robot_1.ino (1.98 KB)

However, when I disconnect and plug in my 9v battery, it waits a while and then starts spinning although there is no obstacle in front of it.

I'm going to guess your 9V battery can't supply the current required to drive the motors. The voltage is probably dropping momentarily below 5V causing the Arduino to reset or "glitch". (Motors draw the maximum current when they are stalled, when they start, and when they reverse.)

What's the voltage & current rating on the motors?

I am using 2 DC motors with a rating of 6v

a 9v battery is used to power the arduino UNO

a 4xAA 6v battery is plugged into the external power outup on the shield

Try a 6xAA battery pack instead of the 9v. The little rectangular 9 volt batteries are weak as water. Check the voltage of that battery when the Arduino is on.

Should i replace the 9v battery with 6 AA

Should i keep the 4 AA battery pack as well to plug in to the shield's external power supply

Yeah. Or better yet, get a phone charger-USB battery, and plug into the usb for power to the Arduino. It should supply at least half an amp, and most of them have some small leds to tell you how much charge is left. Do keep your motors on separate batteries.

Hi,
Do you have a DMM to measure voltages around your project?

Tom...... :slight_smile:

I don't have a voltimeter

NOOOOOOOOOOOOO

Would this product be a good power source

http://www.maplin.co.uk/p/ultramax-1800mah-power-bank-blue-n24ek

The cheapest DMM you can find is fine. Look for a super-bargain that is almost a giveaway for promotional purposes. On the other-hand it's value to you will be immense. When you find one, err on the side of paying too much. You won't regret it.

Chris

ill give you a karma point :slight_smile:

Thanks.

Enjoy your meter. At first I entertained myself measuring the resistance from one hand to the other, etc.