08
Sep
We can connect an LCD and an Ethernet shield simultaneously with an Arduino , without interfering the pins .
In this problem we should know about the pins of Ethernet shield use in this circuit . Ethernet shield using pins
rx ,tx and digital pins 10,11,12,13 . So we don’t select these pins for the LCD connection. Thus we select digital pins 9,8,7,6,5,4 of Arduino for LCD connection .
Sample code:
/*
Connection details :
1. LCD RS pin to digital pin 9.
2. LCD Enable pin to digital pin 8.
3. LCD D4,D5,D6,D7 pins to digital pin 7,6,5,4 respectively.
*/
#include
#include
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 1, 188 };
byte server[] = { 192, 168, 1, 180 }; // Google
Client client(server, 80);
void setup()
{
lcd.begin(16, 2);//setup coloumn and rows
lcd.clear();
lcd.print("Helloworld");
Ethernet.begin(mac, ip);
}
void loop()
{
//Ethernet client
Serial.println("connecting...");
if (client.connect()) {
Serial.println("connected!!!!!!!!!!!!!!!!!!!!!!!");
client.println("http//:............");
client.stop();
}
else {
Serial.println("connection failed");
}
else{
lcd.setCursor(0, 1);
lcd.print("Access denied!");
}
}





