I see ![]()
Now I'm trying out simple code just for giving the Ethernet module an IP, and connecting it directly with a home router via cable (where my desktop is working from, so with internet connection and other clients). This would be so I could simply ping with my desktop to the Arduino, but unfortunately it isn't working.
This is my current code:
// Present a "Will be back soon web page", as stand-in webserver.
// 2011-01-30 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php
#include <EtherCard.h>
#define STATIC 0Â // set to 1 to disable DHCP (adjust myip/gwip values below)
#if STATIC
// ethernet interface ip address
static byte myip[] = { 192,168,0,240 };
// gateway ip address
static byte gwip[] = { 192,168,0,1 };
#endif
// ethernet mac address - must be unique on your network
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
byte Ethernet::buffer[500]; // tcp/ip send and receive buffer
char page[] PROGMEM =
"HTTP/1.0 503 Service Unavailable\r\n"
"Content-Type: text/html\r\n"
"Retry-After: 600\r\n"
"\r\n"
"<html>"
 "<head><title>"
  "Testing website"
 "</title></head>"
 "<body>"
  "<h3>This is the Arduino</h3>"
  "<p><em>"
   "please work :)
"
  Â
  "</em></p>"
 "</body>"
"</html>"
;
void setup(){
 Serial.begin(57600);
 Serial.println("\n[backSoon]");
Â
 if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
  Serial.println( "Failed to access Ethernet controller");
#if STATIC
 ether.staticSetup(myip, gwip);
#else
 if (!ether.dhcpSetup())
  Serial.println("DHCP failed");
#endif
 ether.printIp("IP: ", ether.myip);
 ether.printIp("GW: ", ether.gwip);Â
 ether.printIp("DNS: ", ether.dnsip);Â
}
void loop(){
 // wait for an incoming TCP packet, but ignore its contents
 if (ether.packetLoop(ether.packetReceive())) {
  memcpy_P(ether.tcpOffset(), page, sizeof page);
  ether.httpServerReply(sizeof page - 1);
 }
}
And I try to ping to 192.168.0.240 but it's unreachable.
Also my desktop has the IP: 192.168.135 so it's in the same range.
Regards,
Dries