Arduino mega going rogue, after uploading programm

Hi, guyss,,,,,,,, i m currently experiencing a new problem on my arduino mega R3,

Here is the problem,
*My arduino connects to IDE fine.

  • My arduino gets the programm through usb.

But, wen i connect it with my project, it is responding like a mad, blinking rx tx led unnecessarily(even without usb connected!!), restarts, led blinking on its own wish, but i m sure the program is not getting executed, and the motors dont run, they keep on fluctuating , and my servos acting violently,

pls help me,

I tried bootloading with original bootloader, as well as updated bootloader (watch dog timer fix!!),
I thought since the rx tx leds blinks and lights up even without connected on usb port to pc, i have done flashing DFU in atmega16u2, in the forum and everything went fine without problems, but nothing helps, in solving this issue,
and one more thing is that , it all started with the pin 4 being held HIGH always no matter what you set the pin to be, even to low, but it remains HIGH,

This could be caused by a bad sketch and/or a hardware problem. Show your sketch and show a diagram of what and how everything is connected to your MEGA.

If you can upload the blink sketch and that works without electronics connected then the problem is, as John suggests, probably in either your electronics, the sketch or both.

Here is my code, its a bit lengthy

This is my code and worked fine previously earlier on the same board and with the same electronics!!
I m making this robot as a part of a competetion. pls help me, since my competetion is going to be held on 1-5 jan 2015

grid_navigation.ino (223 Bytes)

gripper_movements.ino (1.94 KB)

IRC_2015.ino (2.41 KB)

line_follow.ino (1.18 KB)

motor_movements.ino (2.75 KB)

There create a folder for IRC_2015 and place all the files in it, and open IRC_2015, so that all opens in main Tab.

This is my connection diagram. and i wish to say again that this schematic with the same code worked perfect on the same arduino mega before, and now it is doing like this problems

Looks like all the things (boards? devices?) are using the same power source. What is that power source? How much current does each device draw?

Note: You appear to be connecting power to the MEGA's power jack. That requires at least 7V to get 5V out of the regulator.

All are connected to a 11.1 V 59Wh li-ion battery, only motors draw 2 amps from the battery and all others are pretty small may be around 100mA per board, and as of arduino we know ourselves!! :grin:

And one more doubt , dont mistake me if am wrong :fearful: :stuck_out_tongue:
Well, is drawing too much current from the battery, may lead to arduino going rouge???

hey guys pls anyone help me......... :confused: :disappointed_relieved:

Yes, if the load is drawing too much current from the battery, it may lead to arduino going rogue, which can seen as hardware resets, typically from the brownout detector on the chip seeing a voltage drop and resetting the processor when the voltage comes back up.