Do Not Use SPI Pins with LCD... Mega 2560

Running into an apparent conflict between the LiquidCrystal library and the Ethernet and UDP libraries. I get invalid characters and such on the LCD. Unfortunately this is entirely expected and completely my fault. So if anyone else hits this, follow the reply below. DO NOT USE pins 50, 51, or 52 except for SPI and do not use pin 53 if you are using the Ethershield.

Why is is that everyone wants to use the SPI pins to connect their LCDs to?

Arduino communicates with both the W5100 and SD card using the SPI bus (through the ICSP header). This is on digital pins 11, 12, and 13 on the Duemilanove and pins 50, 51, and 52 on the Mega. On both boards, pin 10 is used to select the W5100 and pin 4 for the SD card. These pins cannot be used for general i/o. On the Mega, the hardware SS pin, 53, is not used to select either the W5100 or the SD card, but it must be kept as an output or the SPI interface won't work.

LiquidCrystal lcd( 48, 49,[glow] 50, 51, 52, 53[/glow] );

Sorry about that. I think everyone does it (and misses that point) because there is no physical connection to those pins (apparently, since it uses the ICSP header). When the Ethershield is covering the other pins it makes sense that some would be used. On a related note, all the tutorials mention ports 11-13 but nothing about the differences for the Mega. Ignorance is not an excuse though... and the tutorials have to be written with SOME basis of understanding.

Thanks again for the information. That of course solved it.

because there is no physical connection to those pins

No physical connection between what and the SPI pins? The Ethernet shield makes a physical connection to the SPI pins (although it is to the Duemilanove SPI pins which need to be jumpered to the Mega SPI pins.

apparently, since it uses the ICSP header

What does?

The Mega 2560 has SPI on pins 50, 51, and 52. The Ethershield only physically covers pins 0-13, A0 - A5, AREF, 3 GNDs, 5V, 3.3V, and RESET. Pins 14-53, 2 GNDs, 2 5V, and A6-A15 are exposed. I combined the Ethershield and Mega 2560 images to show this.

The 4th paragraph (line 1) of the Ethershield page indicates that it uses the SPI bus through the ICSP header. This would also explain why the Ethershield does not pass the ICSP header through. It is using it.

As for jumpering the pins that does not appear to be necessary. I have not seen any reference to that yet and the Ethershield is working fine at this time.