problem with arduino mega 2560

hello,
i have a problem with arduino mega 2560, when i connected the mega with my laptop, and upload a new sketch, it take it and work properly, but when i remove the usb cable connection, the mega run the older sketch, and when i reconnected with the usb cable the new sktech work.
i tried to reset the arduino but it does not work.
help please.
thank you.

That is magic.
Could you make a small test sketch. For example a sketch that sends a message to the serial monitor.

Older Mega boards sometimes have trouble with uploading the sketch. Arduino version 1.0.4 has an improved bootloader. You need a programmer or an second Arduino as ISP. I don't think it is the bootloader, by the way.

but why when i connect it to serial it take the new sktech ?
and what is the bootloader and how i fix it ?
thank you for your reply.

Here is some information about the bootloader, http://arduino.cc/en/Hacking/Bootloader?from=Main.Bootloader
If you don't know what a bootloader is, you should not try to write the bootloader.

I really don't understand what is going on with the new and the old sketch. It seems impossible to me.

Could you try a small sketch as I suggested, and see what happens ?
Could you explain better what is going on ? Why does the Arduino not reset if you press the reset button ?
Do you have a Arduino 2560 clone from Ebay ?
Could you measure the voltage of the 5V pin ? It should be between 4.5 and 5.0V. If you use the USB to power it, could you try a power supply ?

The symptom as you are describing it is not possible so you are somehow misunderstanding the symptoms you are seeing. Without seeing your sketch code it's not possible to tell anything. Have you tried uploading the simple example blink code and see if it runs after uploading and then unplugging the board and plugging it back in and see if the blink code still runs?

I agree you shouldn't fool with trying to burn a new bootloader onto the chip until you better understand the symptom you are seeing.

Lefty

thank you,
the voltage was 4.5V, and thats what happened, when i connect the mega2560 to external power supply it run an old sktech that i upload as a test to make the car work, and when i writed a code to make the car avoiding obstacles only this sktech work when i connect the mega with the usb cable, yes this what happened. the led flashes two times when i click on the reset button but the car continue to work and no reset has done.
i have an uno too i think should replace the mega with it. :stuck_out_tongue: