Can code for one board, semi-brick another?

Heya!
I have been fiddling about with my Uno and had a lot of fun and learning, and just got my hands on a Mega 2560. While waiting for a bunch of components to arrive from China, I came across some POV (Persistence of Vision) projects and tried to copy and paste the code from: :) my first not-so-good persistence of vision - Exhibition - Arduino Forum onto my Mega and that went... not that good, to say the least. It stalled the card at 95 % and no time-out or anything. Eventually I had to disconnect, but after that, the board seemed corrupted sort of. Basic sketches that I tried earlier wouldn't load, everything was acting weird.

Aaanywho, hours later it seems to be back in order though.

My question is - can code, that was probably for a Uno, really mess up and semi-brick a different board that easily?

can code, that was probably for a Uno, really mess up and semi-brick a different board that easily

No.

So I am not sure what is causing you problems.

Hm, I tried it again, and the same thing happened. It gets stuck at about 95 % and... that's it. Could someone please try it on a Mega 2560 and see if it works just fine, copying and pasting, or if it is just me. Or, if it is something like that three exclamation point bug thingie I read about earlier. :O/

  {0x1e, 0x21, 0x21, 0x21, 0x5e}, //Q

Hey, lookie there. Three exclamation points in a row. An ! is a 0x21.

Aaaaah! Thanks! I was going crazy over it. I haven't programmed in a few years, so I am a bit rusty. I was looking up the functions used, but didn't find any clues. I thought perhaps the PORTD was somehow reserved and not valid for Mega, but that wasn't the case either.

Haha! My random comparison was apparently the very thing that caused it! A little follow up question then, how do I "fix" it? Not the code, but the actual bug itself.

Arduino code such as digitalWrite(2,HIGH); should be compatible between UNO and MEGA but direct port manipulation is not compatible. The PORTD on UNO's chip has arduino pin numbers 0-7. The same port on MEGA's chip is a bit complicated.

You can try PORTA for MEGA pins 22-29, PORTF for MEGA pins 54-61 (analog 0-7), PORTK for MEGA pins 62-69 (analog 8-15), PORTC for MEGA pins 37-30 (reverse order), PORTL for MEGA pins 49-42 (reverse order). PORTB has SPI pins so you may want to stay away from them in case you want to load a POV pattern from SD card in the future.

how do I "fix" it? Not the code, but the actual bug itself.

Which bug are you referring to? The bootloader code that sees three exclamation points in a row as the signal to enter debug mode? If that is the "bug" you are referring to, you could rewrite that portion of the bootloader code to use some other means to enter debug mode.

Or use ISP to load your code if you want to keep the three !.