Ethernet Shield Stop sending web page
hi
i had simple web server set yesterday original code below.
it working fine on local ip , external ip address
today, i've modified code, taking unwanted html code out , changing button sizes.
now won't display page.
i've tried examples, , work ok. send ping cmd works fine, know not cable or router issues.
original code
modified code:
yes port isn't set xxxx in reality.
any ideas?
i had simple web server set yesterday original code below.
it working fine on local ip , external ip address
today, i've modified code, taking unwanted html code out , changing button sizes.
now won't display page.
i've tried examples, , work ok. send ping cmd works fine, know not cable or router issues.
original code
code: [select]
#include <spi.h>
#include <ethernet.h> // initialize libraries.
byte mac[] = { 0xde, 0xad, 0xbe, 0xef, 0xfe, 0xed }; //i left mac address , ip address blank.
byte ip[] = { 192,168,0,21 }; // want fill these in mac , ip address.
ethernetserver server(xxxx); // assigning port forwarded number. it's 80.
string readstring; // using strings keep track of things.
int val; // using val variable pir status.
//////////////////////
void setup(){
pinmode(2, output);
ethernet.begin(mac, ip);
}
void loop(){
ethernetclient client = server.available();
if (client) {
while (client.connected()) {
if (client.available()) { // start server , strings.
char c = client.read();
if (readstring.length() < 100) {
readstring += c;
}
if (c == '\n') {
serial.println(readstring); // , here begin including html
client.println("http/1.1 200 ok");
client.println("content-type: text/html");
client.println();
client.println("<hmtl>");
client.println("<head>");
client.println("arduino page");
client.println("</head>");
client.println("<title>");
client.println("arduino + ethernet page");
client.println("</title>");
client.println("<body bgcolor=black>");
client.println("<font color=white>");
client.println("<meta http-equiv=\"refresh\" content=\"4\">"); // used refresh page so
client.println("<center>"); // can see if there motion or not.
client.println("<b>");
client.println("greetings! here find interactive page served arduino!");
client.println("</br>");
client.println("as well, can interact arduino! it's pretty basic, , can't see it,");
client.println("</br>");
client.println("but press button, turn on or off led or move servo! have fun!");
client.println("</b>");
client.println("<p>");
client.println("<table border=0 width=200>");
client.println("<tr>");
client.println("<td align=center>");
client.println("<font color=white>");
client.println("the temperature is:");
client.println("</td>");
client.println("</tr>");
client.println("<tr>");
client.println("<td align=center>");
client.println("<font color = turquoise size=10>");
//int temp = (((5*analogread(5)*100/1024)*1.8)+32); // replaces 00 temperature in f.
//client.println(temp);
client.println("* f");
client.println("</td>");
client.println("</tr>");
client.println("</table>");
client.println("<p>");
client.println("<form>");
client.println("<input type=button value=led1-on onclick=window.location='/?lighton1\'>");
client.println("<input type=button value=led1-off onclick=window.location='/?lightoff1\'>");
client.println("</form>"); // above , below you'll see when click on button, adds little snippet
// end of url. arduino watches , acts accordingly.
client.println("</center>");
client.println("</font>");
client.println("</body>");
client.println("</html>");
delay(1);
if(readstring.indexof("?lighton") >0) // these snippets arduino watching for.
{
digitalwrite(2, high);
}
else{
if(readstring.indexof("?lightoff") >0)
{
digitalwrite(2, low);
}
}
readstring="";
client.stop(); // end of session.
}
}
}
}
}
modified code:
code: [select]
#include <spi.h>
#include <ethernet.h> // initialize libraries.
byte mac[] = { 0xde, 0xad, 0xbe, 0xef, 0xfe, 0xed }; //i left mac address , ip address blank.
byte ip[] = { 192,168,0,21 }; // want fill these in mac , ip address.
ethernetserver server(xxxx); // assigning port forwarded number. it's 80.
string readstring; // using strings keep track of things.
int val; // using val variable pir status.
//////////////////////
void setup(){
pinmode(2, output);
ethernet.begin(mac, ip);
}
void loop(){
ethernetclient client = server.available();
if (client) {
while (client.connected()) {
if (client.available()) { // start server , strings.
char c = client.read();
if (readstring.length() < 100) {
readstring += c;
}
if (c == '\n') {
serial.println(readstring); // , here begin including html
client.println("http/1.1 200 ok");
client.println("content-type: text/html");
client.println();
client.println("<hmtl>");
client.println("<head>");
client.println("arduino page");
client.println("</head>");
client.println("<title>");
client.println("arduino + ethernet page");
client.println("</title>");
client.println("<body bgcolor=black>");
client.println("<font color=white>");
client.println("<meta http-equiv=\"refresh\" content=\"4\">"); // used refresh page so
client.println("<center>"); // can see if there motion or not.
client.println("<b>");
client.println("simple led switch");
client.println("</br>");
client.println("<form>");
client.println("<input type=button value=led1-on style='width: 200px; height: 60px' onclick=window.location='/?lighton1\'>");
client.println("<input type=button value=led1-off style='width: 200px; height: 60px' onclick=window.location='/?lightoff1\'>");
client.println("</form>"); // above , below you'll see when click on button, adds little snippet
// end of url. arduino watches , acts accordingly.
client.println("</center>");
client.println("</font>");
client.println("</body>");
client.println("</html>");
delay(1);
if(readstring.indexof("?lighton") >0) // these snippets arduino watching for.
{
digitalwrite(2, high);
}
else{
if(readstring.indexof("?lightoff") >0)
{
digitalwrite(2, low);
}
}
readstring="";
client.stop(); // end of session.
}
}
}
}
}
yes port isn't set xxxx in reality.
any ideas?
solved
for reason didn't assigned port. same yesterdays.
now i've changed it, fine.
don't know why happen tho
for reason didn't assigned port. same yesterdays.
now i've changed it, fine.
don't know why happen tho
Arduino Forum > Using Arduino > Networking, Protocols, and Devices (Moderator: fabioc84) > Ethernet Shield Stop sending web page
arduino
Comments
Post a Comment