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?????