Gente buen día, necesito un poco de ayuda espero puedan ayudarme. Logré crear un servidor web el cual lee un potenciometro y enciende un led. Ahora cuando quiero agregar un led mas, la pagina no me carga estoy seguro que es error del codigo html porque ya lo revise y justo cuando agrego el href para el led2 la pagina se cae. Espero me den una mano porque quiero hacer un tuto completito para los que alguna vez puedan necesitar ya que no encontré muchas referencias del funcionamiento del modulo. Dejo el codigo.
#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
BufferFiller bfill;
const int pinLed1 = 2;
const int pinLed2=3;
char* statusLed1 = "OFF";
char* statusLed2 = "OFF";
void setup() {
Serial.begin(57600);
if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
Serial.println( "Falló el acceso a dispositivo ethernet");
#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);
pinMode(pinLed1, OUTPUT);
digitalWrite(pinLed1, LOW);
pinMode(pinLed2, OUTPUT);
digitalWrite(pinLed2, LOW);
}
static word homePage() {
BufferFiller bfill = ether.tcpOffset();
bfill.emit_p(PSTR(
"HTTP/1.1 200 OK\r\n"
"Content-Type: text/html\r\n"
"Retry-After: 600\r\n"
"\r\n"
"<head>"
"<meta http-equiv='refresh' content='3' />"
"</head>"
"<html>"
"<head>"
"<title>"
"Ethernet"
"</title>"
"</head>"
"<body>"
"<div style='text-align:center;'>"
"<h1>Test del Modulo ENC28J60</h1>"
"
Estado del LED 1: $S
"
"<a href='./?data1=0'><input type='button' value='OFF'></a>"
"<a href='./?data1=1'><input type='button' value='ON'></a>"
"
Estado del LED 2: $S
"
"<a href='./?data2=0'><input type='button' value='OFF'></a>"
"<a href='./?data2=1'><input type='button' value='ON'></a>"
"
Pote: $D"
"
"
"</body>"
"</html>"
),statusLed1, statusLed2, analogRead(0));