haxan:
This post is quite old but i wanted some help understanding one difference in Due and Mega.Is the code written for Mega compatible with Due or will i have to make some changes?
Short answer "it depends".
If the code limits itself to not directly touching the internal MCU h/w directly and only uses the
Arduino core library functions or the APIs from the libraries that come with the IDE then the code will work for both.
But by you saying "code written for Mega", I'm assuming you have code that is not really
truly Arduino code in that it violates the Arduino APIs by directly touching hardware.
If that is the case, then no, it will not work on DUE.
That is from a s/w perspective.
Then there is the h/w issue of 5v vs 3v and pin drive capability.