hi guys I'm trying to ping the 8.8.8.8 (google) address
I tried a lot of examples from google with no luck can any help me?
I'm using the w5100 Ethernet shield
here is my code so far
#include <Ethernet.h>
#include <LiquidCrystal.h>
//#include <Ethernet.h>
#include <SPI.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
byte mac[] = {0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02}; // MAC Address of the Ethernet Shield
IPAddress ip(127,0,0,1); //Fall back IP address
EthernetClient client; // Ethernet initialization (port 80 is default for HTTP)
void setup() {
lcd.begin(16, 2);
Serial.begin(9600); //begin serial
}
void loop() {
Ethernet.maintain(); // Keep looking for an IP address
if (Ethernet.begin(mac) == 0){ // start the Ethernet connection, connect to DHCP. {
Ethernet.begin(mac, ip); //if it fails to get an IP from DHCP, use the fall back value
}
printIPAddress(); // print your local IP address:
delay(1000);
lcd.clear();
printGateway();
delay(1000);
lcd.clear();
printDNS();delay(1000);
delay(1000);
lcd.clear();
}
void printIPAddress(){
lcd.clear(); //Clear the LCD
lcd.setCursor(0,0); // Set the cursor on the LCD to Col 1 Row 1
lcd.print("IP address: "); // Print on text on the LCD
Serial.print("IP address: "); // Print text on the serial monitor
lcd.setCursor(0,1); //set the cursor on the LCD to Col 0 Row 2
Serial.println(Ethernet.localIP()); // Print the IP address on the Serial monitor
lcd.print(Ethernet.localIP()); // Print the IP address on the LCD
}
void printGateway(){
lcd.clear(); //Clear the LCD
lcd.setCursor(0,0); // Set the cursor on the LCD to Col 1 Row 1
lcd.print("Gateway: "); // Print on text on the LCD
Serial.print("Gateway: "); // Print text on the serial monitor
lcd.setCursor(0,1); //set the cursor on the LCD to Col 0 Row 2
Serial.println(Ethernet.gatewayIP()); // Print the GW address on the Serial monitor
lcd.print(Ethernet.gatewayIP()); // Print the GW address on the LCD
}
void printSubnetMask(){
lcd.clear(); //Clear the LCD
lcd.setCursor(0,0); // Set the cursor on the LCD to Col 1 Row 1
lcd.print("Subnet Mask: "); // Print on text on the LCD
Serial.print("Subnet Mask: "); // Print text on the serial monitor
lcd.setCursor(0,1); //set the cursor on the LCD to Col 0 Row 2
Serial.println(Ethernet.subnetMask()); // Print the Subnet Mask on the Serial monitor
lcd.print(Ethernet.subnetMask()); // Print the Subnet Mask: on the LCD
}
void printDNS(){
lcd.clear(); //Clear the LCD
lcd.setCursor(0,0); // Set the cursor on the LCD to Col 1 Row 1
lcd.print("DNS Server: "); // Print on text on the LCD
Serial.print("DNS Server: "); // Print text on the serial monitor
lcd.setCursor(0,1); //set the cursor on the LCD to Col 0 Row 2
Serial.println(Ethernet.dnsServerIP()); // Print the DNS Server on the Serial monitor
lcd.print(Ethernet.dnsServerIP()); // Print the DNS Server on the LCD
}