Upgrading from Ardiono Uno to Ardiono Mega Due to Lack of Memory

Hi, So I had a working sketch and hardware on my Ardiono Uno but I need to load a few too many libraries and it turns out that there was not enough memory to accomplish my goals. So, after some research I discovered that I could upgrade to the Ardiono Mega and still be able to use my CC3000 wifi shield. Great! I thought I could simply plug the WiFi shield into my Mega and instantly get the extra memory and nothing else would have to change. I guess I was wrong as although my sketch compiles and uploads and appears to be partially functioning, in that the wifi module works along with some LED/buttons. Unfortunately my LCD screen (using shift register) no longer works and nor does my relay.

I've not changed any of the connectors as everything was connected via the WiFi shield.

For the LCD I'm using pins 2, 11, 13 as shown on the Wifi Shield/old Ardiono Uno.

For the 2 relays I'm using the analogue pins A0 and A1.

I wonder if there is anything obvious I've overlooked?

OK, so I noticed that the MOSI and SCK pins are not in the same place. Apparently the MOSI pin has moved from pin 11 on the Uno to pin 51 on the Mega and the SCK pin has moved from 13 on the Uno to 52 on the Mega.

So, I went back to basics with a breadbord setup for the LCD (with shift register) and the basic hello world sketch to see if I'd broken something...

Uno using MOSI (11), SCK (13) and Latch (2) - Which works: -

Mega using MOSI (51), SCK (52) and Latch (2) - Doesn't work: -

I don't suppose anyone can spot where I went wrong?

Does the code refer to the pins used anywhere? Have you made sure to fix any and all instances of uno pin numbers being used instead of Mega pin numbers?

Hi and thanks for the reply. I'm using the most basic example I could think of. That is the modified library for the LCD (with shift register) as described here. The only hard coded pin is the latch which I set to 2 in the instantiate method.

Full code is as follows for the example above.

#include <SPI.h>

//some comments missing here but they will be in the original sketch

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the number of the sspin 
//(or the latch pin of the 74HC595)
LiquidCrystal lcd(2);

void setup() {
  // set up the LCD's number of columns and rows: 
  lcd.begin(20, 4);
  // Print a message to the LCD.
  lcd.print("hello, world!");
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  
  lcd.print(millis()/1000);    
    
  // print the number of seconds since reset:

}

OK I fixed it! There were 2 newb mistakes here! Firstly because I misinterpreted the numbering of the pins and didn't notice that the last 2 pins on the rail were ground which caused me to plug the MOSI and SCK into the wrong place. I noticed this when I used double checked by connecting directly to the ICSP pins (used for shield compatibility). The second issue which caused my relays not to function was because I was listing pins A0 and A1 as 14 and 15. This numbering system does not appear to map over and by specifying A0 and A1 instead in my code, this all works just fine!