SunilV:
I changed from UNO to Mega and my robot head is
going haywire.[...]
INT in UNO is 32 bit and on Mega its 64. if the code needs to be changed
let me know.
On both an Uno and Mega an int is 16 bits.
What exactly do you mean by "going haywire"? What actually happens, and what should happen?
Post a diagram showing how you have everything connected. A photo of a pencil drawing will be great. Please don't use FRITZING.
And please modify your post and use the code button </> so your code looks like this and is easy to copy to a text editor. See How to use the Forum Your code is too long for me to study quickly without copying to a text editor.
...R