Of all the boards that I have, the Arduino Mega is the most critical with voltage range and glitches when connecting and disconnecting. Just touching the GND pin can be enough to cause such a glitch.
If you have a cheap clone, then it is worse. The official Arduino boards are better quality.
Perhaps you could add extra capacitors to 5V and GND. Or make the reset circuit lower impedance.
Could you check if there is a safety diode from the /RESET pin to 5V.
I think the diode is here: [EDIT] The black thing could be the diode and the little thing could be the 22pF capacitor. Then there must be a 10k resistor somewhere else.
The Serial port could get a burst of data or the reset circuit might get triggered or the sketch will halt.
Can you do a few tests ?
What is the voltage of the 5V pin when it is running ? It must be above 4.5V.
What happens if you press the reset button when it the board is in a erroneous state, does it normally start ?
It doesn't HAVE to be above 4.5v. Mine runs even when it is down to 3.6v without issues.
@vjgeorge
I can't even compile your code... There are SO MANY errors I don't know where to begin...
C:\Users\hopin\Documents\Arduino\HelpDudeonForum\Help_Dude_on_Forum.ino\Help_Dude_on_Forum.ino.ino: In function 'void setup()':
Help_Dude_on_Forum.ino:7:28: error: 'DDRA' was not declared in this scope #define DATA_DDR DDRA
^
C:\Users\hopin\Documents\Arduino\HelpDudeonForum\Help_Dude_on_Forum.ino\Help_Dude_on_Forum.ino.ino:34:3: note: in expansion of macro 'DATA_DDR'
DATA_DDR |= (1 << DATA_PIN);
^~~~~~~~
C:\Users\hopin\Documents\Arduino\HelpDudeonForum\Help_Dude_on_Forum.ino\Help_Dude_on_Forum.ino.ino:7:28: note: suggested alternative: 'DDRB' #define DATA_DDR DDRA
^
C:\Users\hopin\Documents\Arduino\HelpDudeonForum\Help_Dude_on_Forum.ino\Help_Dude_on_Forum.ino.ino:34:3: note: in expansion of macro 'DATA_DDR'
DATA_DDR |= (1 << DATA_PIN);
^~~~~~~~
C:\Users\hopin\Documents\Arduino\HelpDudeonForum\Help_Dude_on_Forum.ino\Help_Dude_on_Forum.ino.ino: In function 'void ws2811_sendarray(uint8_t*, uint16_t)':
Help_Dude_on_Forum.ino:6:28: error: 'PORTA' was not declared in this scope #define DATA_PORT PORTA
^
C:\Users\hopin\Documents\Arduino\HelpDudeonForum\Help_Dude_on_Forum.ino\Help_Dude_on_Forum.ino.ino:97:22: note: in expansion of macro 'DATA_PORT'
masklo =~ maskhi & DATA_PORT;
^~~~~~~~~
C:\Users\hopin\Documents\Arduino\HelpDudeonForum\Help_Dude_on_Forum.ino\Help_Dude_on_Forum.ino.ino:6:28: note: suggested alternative: 'PORT0' #define DATA_PORT PORTA
^
C:\Users\hopin\Documents\Arduino\HelpDudeonForum\Help_Dude_on_Forum.ino\Help_Dude_on_Forum.ino.ino:97:22: note: in expansion of macro 'DATA_PORT'
masklo =~ maskhi & DATA_PORT;
^~~~~~~~~
exit status 1
'DDRA' was not declared in this scope
You will have to compile for a Mega, not something else.
Outside spec (see 2560 datasheet), so no guarantee that that will be the case for another 2560. A 328P is a more forgiving, from memory 3.6V is the limit for it.
A board will only draw what is needed. Same as a lightbulb in your house; the fuse is (as example) 16A, the bulb is e.g. 0.5A (60W @120V).
If the 70A would go through the board or a breadboard, it will be a problem for the board (not the processor). Note that in below drawing, the 70A will not go through the Mega.
I have a old Arduino Mega R2 board and its ATmega2560 was manufactured with a older process. It does need more than 4.5V.
With 70 Amps to the leds, the returning current in the GND wire is also 70A. That can really mess up your Arduino board. Can you show a photo of your wiring ? Perhaps a amplifier or optocoupler is needed.
I assume that you have a clone Mega board. Then it is probably missing capacitors and it is noisy. You could add a few capacitors.
If pressing the reset button does nothing, then something really bad happened. Perhaps you have to redesign your project and wiring. There are enough Arduino users that are familiar with such high currents and ledstrips and can help, so I have good hopes that it can be fixed.
If a sketch runs, then the sketch runs from Flash memory. It is there, in the Flash memory. Forever.
Unless you have a very cheap noisy board without the protection diode and enormous amounts of noise or ground currents, then the board could enter the High Level Programming mode. That usually corrupts the bootloader, so maybe everything I just wrote is nonsense Maybe the bootloader gets triggered and starts programming. I don't know if that is possible.
Can you check if that is a 10k resistor in the red circle and that the top is connected to the 5V and the bottom to the RESET pin and the reset button ?
I don't understand why it is bigger than other resistors. I assume that a diode has a marking for the direction, I'm very confused.
But either the resistor or diode is missing.
This is the reset circuit of the official Arduino Mega:
The 10k resistor lowers the impedance for the RESET pin and the diode prevents accidentally entering the High Voltage Programming mode. The 22pF capacitor dampens glitches and noise.
You could do a test. Add a 10k resistor and diode from the RESET pin to the 5V pin. If that works, add the 22pF as well. Then also add a few decoupling capacitors for the 5V.
Note that even with the right circuit, the Arduino Mega is the board that is still sensitive for noise and glitches.
That is possible. For example a glitch on the Serial port causing a loop with a stuck interrupt or so. But I don't see that in the code and I had similar problems with my Mega clone. So let's upgrade the hardware first.
There are more things that you can test and do:
Did you add a capacitor to the GND and 5V pin of 100µF or 1000µF or so.
Can you show a photo to show how the ground wires are going.
You could test disconnecting the USB with a laptop that is not connected to the mains, then a laptop that is connected to the mains, then a desktop computer. There might be a nasty ground difference between the desktop and your power supply.
Test with a other Arduino board, but not another Mega board.
Change the interrupt routine, prevent that 'ptr' and 'pos' go beyond the bounderies.