Ethernet shield2 with LCD Module sd dont work

Hello, I´m trying to use arduino uno + ethernet shield2 + lcd module sd card reader.
I´m reading that if I use ethernet shield with lcd module I have conflict with SPI.
If I use separately I can´t have problems (lcd works fine, ethernet shield works fine), but when I use ethernet + lcd the arduino board it´s not work.
I read that change Pin 10 to Pin 7 to use CS LCD may run ok, but I can´t work. I compiled and send to arduino but arduino is blocked.
some code:
#include <SPI.h>
#include <Ethernet2.h>
#include <TFT.h> // Arduino LCD library

byte mac[] = { 0x05, 0x1E, 0x14, 0x00, 0x04, 0x00 };
IPAddress ip(174,65,4,65);
EthernetServer server(80);

// pin definition for the LCD
#define cs 7 //changed from pin 10
#define dc 9
#define rst 8

// create an instance of the library
TFT TFTscreen = TFT(cs, dc, rst);

boolean stringComplete = false; // String is completed?
String inputString = ""; // String reading from ethernet
char StringRebut[40];//send to TFT

void setup()
{
// Inicia el puerto serie.
Serial.begin(9600);

// Ethernet
Ethernet.begin(mac, ip);
server.begin();
Serial.print("IP local del servidor ");
Serial.println(Ethernet.localIP());

// Put this line at the beginning of every sketch that uses the GLCD:
TFTscreen.begin();

// clear the screen with a black background
TFTscreen.background(0, 0, 0);//pinte en negre la pantalla

}
void loop()
{

EthernetClient client = server.available(); //any client available????
if (client)
{ // client connected
Serial.println("New client");
boolean currentLineIsBlank = true;
while (client.connected())
{ // Repite mientas existe clientes conectados:
if (client.available())
{
char c = client.read();
// Serial.write(c); // Imprime por el puerto serie la petición del cliente (caracter a caracter)
if (c == '\n')
{
// Se envia la respuesta a una petición de un cliente cuando a finalizado la petición:

              stringComplete = true;
              break;
            }
            else
            {
              inputString += c;
              }

       }
   }
delay(1); // Espera para dar tiempo al navegador a recivir los datos.
client.stop(); // Cierra la conexión.
Serial.println("Client disconnected.");
}


 if (stringComplete) 

{

   actualitzar_display();
   Serial.print("Missatge rebut: ");
   Serial.print(inputString);

}

}

void actualitzar_display()
{

TFTscreen.setTextSize(2);
// erase the text you just wrote
TFTscreen.stroke(0,0,0);//EL TORNE A ESCRIURE DE COLOR NEGRE --> EL BORRE xDDDDDD
TFTscreen.text(StringRebut, 0, 0);

// set the font color
TFTscreen.stroke(255,0,0);//pinte de color roig el següent text

// convert the reading to a char array
inputString.toCharArray(StringRebut, 40);

// print the value
TFTscreen.text(StringRebut, 0, 0);

delay(1000);

 // clear the string:
inputString = "";
stringComplete = false;

}

any suggestion?????

What are you saying " I compiled and send to arduino but arduino is blocked."? Are you saying you cannot upload code? Is there anything connected to pins 0 and 1? Are you getting errors. Try closing the IDE and restart it.

Hello gilshultz,
This problem is very common, a lot of person have the same problem.
The problem is pin conflicts with pin 12 MISO. Ethernet Shield and TFT screen uses the same PIN.
When I connected PIN12 (MISO) from TFT to Arduino uno, the Arduino don´t see ethernet shield (Arduino is running, but without ethernet shield and TFT screen).

I solved modifying in library "Adafruit_ST7735.h" the following line:
Original: #define ST7735_PTLON 0x12
Change: #define ST7735_PTLON 0x05
When I change the line in the library and connect MISO from TFT to pin 5 of arduino all is ok.
I can use Ethernet shield v2 with TFT together now!!!!
Thx.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.