hey guys i wanted to create a simple webserver whith toggle to turn of multiple leds 5 maybe
i am using enc28j60 breakout board
i came across a toggle web server code using ethershield library, it was easy to understand but that library is not working with my breakout board i dont know whats the problem
so i tried other library called ethercard and it seems to work fine, but i cant understand it properly to write a code to make run toggle webserver to control leds
// 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,1,200 };
// gateway ip address
static byte gwip[] = { 192,168,1,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>"
"Service Temporarily Unavailable"
"</title></head>"
"<body>"
"<h3>This service is currently unavailable</h3>"
"<p><em>"
"The main server is currently off-line.
"
"Please try again later."
"</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(){
// DHCP expiration is a bit brutal, because all other ethernet activity and
// incoming packets will be ignored until a new lease has been acquired
if (!STATIC && ether.dhcpExpired()) {
Serial.println("Acquiring DHCP lease again");
ether.dhcpSetup();
}
// 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);
}
}
here is the basic code which just displays service unavailable so can any one help me to write a code using this library, it would be really useful
and the functionality can be as simple as shown in this video Arduino 1.0 with enc28j60 Ethernet Shield V1.1 - YouTube
thank you
EtherCard.rar (44.1 KB)