change from arduino uno to arduino mega

hello, i'm currently working on a led cube. I bought first an arduino uno, the code works fine and the cube does his job perfectly. i wrote a lot of animations an the memory of the arduino was to small. So i bought an arduino mega today. Unfortunately when i upload the code to the arduino mega, the cube does nothing. I've read there are some differences in the way of coding, but normally i should work (how far I've read). Do i need to make changes to make it compatible? This is the link to the code: "https://pastebin.com/VUeVNgmE", Thanks in Advance

The SPI pins are different between Uno & Mega. On the Mega the SPI ports are: MISO - 50 MOSI - 51 SCK - 52 SS - 53

i tried it, but i doesn’t seems to work :frowning: It shows the next error

C:\Users\sebastiaan\Desktop\cubus programmas\animaties gecombineerd - mega\Cube0_0\Cube0_0.ino: In function 'void __vector_13()':

C:\Users\sebastiaan\Desktop\cubus programmas\animaties gecombineerd - mega\Cube0_0\Cube0_0.ino:19:25: warning: left shift count >= width of type [enabled by default]

 #define SR_BLANK        53                 // shift register output enable - any non SPI pin

                         ^

C:\Users\sebastiaan\Desktop\cubus programmas\animaties gecombineerd - mega\Cube0_0\Cube0_0.ino:1775:18: note: in expansion of macro 'SR_BLANK'

   PORTD |= (1 << SR_BLANK);                      // temporarely disable the SR outputs

                  ^

C:\Users\sebastiaan\Desktop\cubus programmas\animaties gecombineerd - mega\Cube0_0\Cube0_0.ino:18:25: warning: left shift count >= width of type [enabled by default]

 #define SR_LATCH        52                 // shift register latch         - any non SPI pin

                         ^

C:\Users\sebastiaan\Desktop\cubus programmas\animaties gecombineerd - mega\Cube0_0\Cube0_0.ino:1783:19: note: in expansion of macro 'SR_LATCH'

   PORTD |=  (1 << SR_LATCH);                     // set latch pin LOW

                   ^

C:\Users\sebastiaan\Desktop\cubus programmas\animaties gecombineerd - mega\Cube0_0\Cube0_0.ino:18:25: warning: left shift count >= width of type [enabled by default]

 #define SR_LATCH        52                 // shift register latch         - any non SPI pin

                         ^

C:\Users\sebastiaan\Desktop\cubus programmas\animaties gecombineerd - mega\Cube0_0\Cube0_0.ino:1784:19: note: in expansion of macro 'SR_LATCH'

   PORTD &= ~(1 << SR_LATCH);                     // set latch pin HIGH - SR outputs now have new data

                   ^

C:\Users\sebastiaan\Desktop\cubus programmas\animaties gecombineerd - mega\Cube0_0\Cube0_0.ino:19:25: warning: left shift count >= width of type [enabled by default]

 #define SR_BLANK        53                 // shift register output enable - any non SPI pin

                         ^

C:\Users\sebastiaan\Desktop\cubus programmas\animaties gecombineerd - mega\Cube0_0\Cube0_0.ino:1785:19: note: in expansion of macro 'SR_BLANK'

   PORTD &= ~(1 << SR_BLANK);                     // re-enable the SR outputs

                   ^


De schets gebruikt 14.454 bytes (5%)  programma-opslagruimte. Maximum is 253.952 bytes.
Globale variabelen gebruiken 426 bytes (5%) van het dynamisch geheugen. Resteren 7.766 bytes voor lokale variabelen. Maximum is 8.192 bytes.

Direct port addressing, interrupts and timers are different on the Mega. It looks like you use all of them.

Do you have an idea where i can find a site that explains the diffrences or gives some code examples to change my code? Thanks in advance

One problem I see is that you have re-defined SPI pins where the comment clearly states [u]"ANY NON SPI PIN"[/u]. If a language problem, NON SPI PIN means do [u]not[/u] use an SPI pin, use a pin that does not have a secondary operation that may interfere or be interfered with in your application.

Try Googling for "Uno to Mega".