Problems Running Arduino Program

Hello. I'm new in Arduino and I'm trying to do my first simple project. I made an obstacle avoiding robot thanks to this video: Arduino: How To Build An Obstacle Avoiding Robot - YouTube

I made exactly the same, with the same program. When I connect my arduino robot(with arduino mega 2500) to the PC the program runs perfectly; but when i deconnect it from the PC it doesn't run.

Thanks for your help.

Welcome to the Forum. Please read the two posts at the top of this Forum by Nick Gammon on guidelines for posting here, especially the use of code tags ("</>") when posting source code files. Also, before posting the code, use Ctrl-T in the IDE to reformat the code in a standard format, which makes it easier for us to read.

When I connect my arduino robot(with arduino mega 2500) to the PC the program runs perfectly; but when i deconnect it from the PC it doesn’t run.

Sounds like a possible power supply issue. How are you powering your bot?

B4ONE:
when I disconnect it from the PC it doesn't run.

That means you have simply not connected a power supply (battery or such) to the Arduino. :roll_eyes:

(Note I use the word "simply" with some irony.)

Thanks, i thought i used the suficient power supply.

I used 4 AA forthe adafruit motor shield and a 9v battery for the arduino mega.
I will try to put more power supply but i have to say that i don't know how to put more supply :sweat_smile:

B4ONE:
I will try to put more power supply but i have to say that i don't know how to put more supply

It is not a matter of "more power"; the fact is, something at present is not connected.

Well, maybe it is "more power". When you say "9V battery", surely you do not mean this? :astonished:

YES I DO

Well that is probably most of your problem, isn't it? Use six (alkaline of course) AAs.