Mega 2560 with ethernet shield and 16x4 LCD display

Hey,

I have a problem when i’m trying to use my arduino mega 2560, with my ethernet shield, and LCD display at the same time.

When i use the lcd without “Ethernet.begin” phrase all goes fine with the display, but as you already expect, there is no ethernet functionality. When adding this line, the LCD goes blank.

I think there are no overlapping pins. But further i have no clue. Somebody please help me?

Thanks,
Nico

Here some demo code:

/*
  LiquidCrystal Library - Serial Input
 


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

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(52, 48, 44, 42, 40, 38);

byte mac[] = { 0xDE, 0xAD, 0xBA, 0xAF, 0xFA, 0xAD };
byte ip[] = { 192, 168, 0, 177 };
byte gateway[] = { 192, 168, 0, 1 };
byte subnet[] = { 255, 255, 255, 0 };

void setup(){
    // set up the LCD's number of columns and rows: 
  lcd.begin(16, 4);
  // initialize the serial communications:
  Serial.begin(9600);
  Ethernet.begin(mac, ip); //When commenting this line, LCD WORKS!!!!
}

void loop()
{
  // when characters arrive over the serial port...
  if (Serial.available()) {
    // wait a bit for the entire message to arrive
    delay(100);
    // clear the screen
    lcd.clear();
    // read all the available characters
    while (Serial.available() > 0) {
      // display each character to the LCD
      lcd.write(Serial.read());
    }
  }
}

The ethernet shield is using the same pins you are using for your LCD shield. They both use SPI. You could attempt some version of non-hardware SPI (there's a demo on the macetech site) for the LCD, and move the pins that the LCD is using to something other than pins 4, and 9-13, which the Ethernet Shield is using.

On the Mega, SPI (which is used by the Ethernet shield) uses pins 50 to 53. The LCD can use any pins, so move the one on 52 to another pin.

PaulS: On the Mega, SPI (which is used by the Ethernet shield) uses pins 50 to 53. The LCD can use any pins, so move the one on 52 to another pin.

Thanks! I didn't know these pins where SPI pins. My stupid mistake! Now it's fixed. :)